I have a AdvStringGrid with 8 columns, column 5 is editable.
goEditing is true.
The user can quickly enter data, when he presses [Enter] the cell is validated and properly drops down to the next row. Works great.
I am struggling however to have a way to allow using a picklist (clicking on a listbox from a different part of the form) be used to pick a value, insert it into the cell, then allow editing.
When I try that, the column advances, the cell where I inserted the value does not do a OnCellValidate.
i have tried many combinations of settings.
For example , assuming "S' was returned from the picklist click :
GridE.Cells[5, GridE.Row] := S;
GridE.Col := 5;
GridE.SetFocus;
GridE.ShowInplaceEdit;
"S" goes into the cell, but the grid immediately advances to the next column (which is not editable) and the cell validate for the cell I put the text into never happens.
Is the something simple I am missing ?
Delphi Seattle, VCL
Thanks,
John
Hi John,
heve you try to handle the CellChanging event ?
Something like
procedure Form1.AdvGrid1CellChanging(Sender: TObject; OldRow, OldCol, NewRow,
NewCol: Integer; var Allow: Boolean);
begin
Allow:=False;
if (NewCol=5) then Allow:=True;
end;
In this way you force the cursor to stay in column 5.
Regards
Daniele
If you programmatically update a cell, this won't trigger OnCellValidate. OnCellValidate is only triggered when you edit a cell via the UI.
Other than this, I'm not sure what exactly your picklist is doing, how it possibly interferes with the grid. Are you sure you call the code that updates the grid after you are 100% sure nothing will move the focus possibly back to the picklist? A focus change is one possible cause for the grid to stop editing and move to a next cell.