Question

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.

Was it helpful?

Solution

Why not simple:

View.OptionBehavior.FocusFirstCellOnNewRecord = True, 
View.OptionBehavior.GotoNextCellOnEnter = True, 
View.OptionData.Appending = True

OTHER TIPS

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;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top