I use TeeGrid with a dataset in Delphi Firemonkey and need to manually type in a new value for a cell. I have seen the demo which works with the TeeGrid defined with Editing.AutoEdit := true and Editing.DblClick := true but currently use the TeeGrid OnDblClick event for other processing (comparing values between grid columns and colouring cells to reflect equivalence) so this does not work.
I have tried to do a single click on a cell and then start typing new text for that cell but this also does not work.
Suggestions for how to get this to work would be appreciated.
What controls whether this allows editing of the underlying dataset or not? When trying this the grid seems to go into edit mode but I am not allowed to change any value in the field so I presume that is something related to the dataset.
procedure TFormCellEditors.CBAutoEditClick(Sender: TObject);
begin
// When True, pressing any key will show the cell editor automatically.
// When False, only pressing F2 or double-clicking the cell starts editing.
TeeGrid1.Editing.AutoEdit:=CBAutoEdit.Checked;
end;
Note that editing is only taking place to the Grid, that is a copy of data from the underlying datasource and that changes should be written back to that datasource if those changes are acceptable.
Thanks Marc. I am aware of the demo examples you refer to and the use of AutoEdit. I also realise that the grid is a ‘view’ of the data in the dataset, not of the data themselves but my issue is what controls whether one can edit the value in the grid to then be able to update it back to the dataset. Double click is not an option in my case because I use that for another purpose. F2 clearly tries to start the edit process in that it activates the grid cell for editing but does not allow one to enter any new value in the cell.
Do I somehow need to capture the F2 keypress to then activate editing on the dataset? I thought that AutoEdit effectively does just this. Demos just automatically work and any simplified test example also does so but, once I have the additional DblClick functionality, I can’t get F2 editing to work.
Any suggestions for what to look for or to change in other settings, either for the dataset ( a FDQuery) or the TeeGrid? All is being done in Firemonkey (FMX) with Delphi 13 and the most recent TeeGrid version.
…then adding a DblClick event to TeeGrid1 to call that method. The dblclick on a cell runs the code and remains on the cell to edit. I understand that behaviour may no be a full reflection of what you use dblclick for, but using the F2 in this case activates the edit correctly.
Can you add any comments to help me get this project nearer to the problem? ..or a test project if possible.