1

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.

2 Answers2

4

Why not simple:

View.OptionsBehavior.FocusCellOnCycle = True,
View.OptionBehavior.FocusFirstCellOnNewRecord = True,
View.OptionBehavior.GotoNextCellOnEnter = True, 
View.OptionData.Appending = True
Branko
  • 1,384
  • 1
  • 16
  • 35
  • RIGHT!! wth was I thinking?! altho' I believe I also set the above properties and didn't work for some reason, might be because I screwed with events and other stuff, at any rate thank you for your answer works perfectly!! –  Jan 22 '11 at 12:39
  • 1
    To make it work I need add also View.OptionsBehavior.FocusCellOnCycle = True – Krystian Bigaj Mar 31 '15 at 08:16
0

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;