Domanda

Sto lottando per fare un TcxGrid per aggiungere un nuovo record ogni volta che l'utente preme Invio chiave sull'ultimo campo del record corrente, però non ho trovato alcuna proprietà che potrebbe aiutarmi a raggiungere questo obiettivo.

Ho provato a fissare l'evento OnKeyDown della vista griglia (TcxGridDBTableView), con il seguente codice

if Key = VK_RETURN then
  if PaymentViewBetragNetto.Focused then
    PaymentView.DataController.AppendRecord;

ma il codice non viene eseguito per qualche motivo ...

Qualche idea su come accodare record nell'ultimo campo OnEnter evento sarebbe molto apprezzato.

Grazie.

È stato utile?

Soluzione

Why not simple:

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

Altri suggerimenti

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;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top