TAdvInplaceEdit: KillFocus deltes cell text

Version: 8.1.3.0

Problem: if the Focus changes from the underlying grid to something else and the InplaceEditor is open, the text in the cell will be set to an empty string, effectivly deleting the entry.

This is especially problematic with data aware grids.


I've looked through the Code and identified the Problem:

In the WMKillFocus method of TAdvInplaceEdit there is a case if the new Focus is different from the Grid (msg.FocusedWnd <> FGrid.Handle). In this case the variable Text is defined as FGrid.CurrentCell

This can't work under those circumstances, as CurrentCell in the end refers to the VCL-property Cells, which in it's getter tries to create a TStringSparseList object which expects a Row number. I suspect without the Focus, the row number can't be determined. In any case the StringSparseList will be Nil and thus Cells returns an empty string.

So, FGrid.CurrentCell can't be used to get the cell text - but the more pressing question is: why is Text even set in this case?
If I understand it correctly what this would do (if it would work) is to discard the changes the user may have made. But why?

I have deleted this line which fixes the outlined problem. I have also not discovered any negative side effects, though I've not conducted an exhaustive test.

Has this been fixed in a newer Version?


I cannot reproduce an issue with this here.

Grid.ValidateCell() takes care of first updating the current edited cell.
If you somehow have a grid configured in a specific way that causes an issue with this, can you please provide us with sufficient details to allow us to reproduce this here?

Ok, I conducted some more Tests.

I started with an completely unmodified TDBAdvGrid.
Then added goEditing to the grid Options to enable the inplace edit.

Result: no problematic behaviour.

Then I looked into how our grids are usually set up. I was able to narrow it down to one property: EditPostMode

The default is epCell. If you change that to epRow, the problem occurs.

To sumarize, steps to reproduce the issue:

1. Take a TDBAdvGrid
2. Change EditPostMode to epRow
3. Add goEditing to Options


I've honestly no idea what EditPostMode does, and how epRow and epCell differ from each other.

I have retested this here with the ADOEditing demo in the DBAdvGrid samples folder by setting EditPostMode = epRow and I cannot see an erratic behavior with the latest version.

EditPostMode = epCell : a DB post is done after each cell editing ends

EditPostMode = epRow: a DB post is done when the user moves to a different row