cxGrid new record on last field Enter
سؤال
I'm struggling to make a TcxGrid to append a new record whenever the user presses Enter key on last field of the current record, however I didn't find any property that might help me achieve this.
I tried setting the OnKeyDown event of the grid view(TcxGridDBTableView), with the following code
if Key = VK_RETURN then
if PaymentViewBetragNetto.Focused then
PaymentView.DataController.AppendRecord;
however the code is not executed for some reason...
Any idea on how to append record on last field OnEnter event would be highly appreciated.
Thank you.
المحلول
Why not simple:
View.OptionBehavior.FocusFirstCellOnNewRecord = True,
View.OptionBehavior.GotoNextCellOnEnter = True,
View.OptionData.Appending = True
نصائح أخرى
It seems that the way to solve this is to set the OnEditKeyDown/Up/Press of the grid view in order to handle this type of functionality, therefore:
procedure XXX.PaymentViewEditKeyUp(Sender: TcxCustomGridTableView;
AItem: TcxCustomGridTableItem; AEdit: TcxCustomEdit; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_RETURN then
if PaymentViewBetragNetto.Focused then begin
ADataModule.ATable.Append;
PaymentViewAccount.FocusWithSelection;
end; // if PaymentViewBetragNetto.Focused then begin
end;
لا تنتمي إلى StackOverflow