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