【问题标题】:Change field value in the cxgrid when changing another更改另一个时更改 cxgrid 中的字段值
【发布时间】:2013-03-31 00:30:39
【问题描述】:

在我的 cxGrid 中,我有一个 Yes/No 字段,默认为 'NO' 。在那个字段旁边,我有另一个字段,一个 LookupComboBox 字段 从另一个表中获取其值。默认情况下它是空的,但是我希望这样,当值在此更改时 特定字段,我的是/否字段应更改为“是”(仅在我当前正在编辑的行中)我该怎么做?也不确定在哪里实现代码....OnChange,Oneditvaluechanged,Onvalidate ???

【问题讨论】:

  • 不知道 cxGrid,但听起来您正在使用内联编辑。因此,对于包含组合框的列,您可能需要内联编辑器的 OnChange 处理程序。在该处理程序中,您必须限制自己编辑连接到网格的数据源/数据集的当前记录。

标签: delphi devexpress delphi-xe2 delphi-xe


【解决方案1】:

由于您的网格要绑定在数据集上,一种简单的方法是使用选择字段的 fieldchange 事件。
对于即时行为,您应该在数据集中使用带有 ImmediatePost 的 TcxEditRepositoryLookupComboBoxItem 而不是 Lookupfield(无论如何,这至少是 ADO 的更糟糕的方法)

procedure TForm4.MainSelectionChange(Sender: TField);
begin

   if Main.State in [dsEdit,dsInsert] then
      if not Sender.IsNull then
        MainYesNo.Value := true;

   { maybe you are looking for that instead the code above
   if Main.State in [dsEdit,dsInsert] then
        MainYesNo.Value := not Sender.IsNull
   }
end;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-04-29
    • 1970-01-01
    • 2020-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多