1

每当用户在当前记录的最后一个字段上按 Enter 键时,我都在努力使 TcxGrid 追加一条新记录,但是我没有找到任何可以帮助我实现这一目标的属性。

我尝试使用以下代码设置网格视图(TcxGridDBTableView)的 OnKeyDown 事件

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

但是由于某种原因代码没有执行......

任何关于如何在最后一个字段 OnEnter 事件上附加记录的想法都将受到高度赞赏。

谢谢你。

4

2 回答 2

4

为什么不简单:

View.OptionsBehavior.FocusCellOnCycle = True,
View.OptionBehavior.FocusFirstCellOnNewRecord = True,
View.OptionBehavior.GotoNextCellOnEnter = True, 
View.OptionData.Appending = True
于 2011-01-22T12:33:07.877 回答
0

似乎解决此问题的方法是设置网格视图的 OnEditKeyDown/Up/Press 以处理此类功能,因此:

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;
于 2011-01-22T11:54:33.523 回答