DevExpress 未绑定列事件未触发,WinForms

DevExpress Unbound column event not firing, WinForms

我创建了一个未绑定的列,我打算用计算的数据填充它;但是,我无法触发 CustomUnboundColumnData 事件。我基本上从 https://documentation.devexpress.com/#WindowsForms/CustomDocument1477

上的 DevExpress 文档中复制了代码

根据发现的其他帖子,我确保没有其他同名的列。 新的未绑定列确实出现在网格中,但事件从未触发,所以我不知道如何填充它。

在我的构造函数中,我定义了如下列:(我确保没有其他同名的列)

        GridColumn testColumn = new GridColumn();
        testColumn.FieldName = "Test Column1";
        testColumn.VisibleIndex = gridView1.Columns.Count;
        testColumn.UnboundType = DevExpress.Data.UnboundColumnType.DateTime;
        // Disable editing.
        testColumn.OptionsColumn.AllowEdit = true;
        // Specify format settings.
        testColumn.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
        testColumn.DisplayFormat.FormatString = "d";
        testColumn.Visible = true;
        gridView1.Columns.Add(testColumn);

然后我有了永远不会触发的事件函数

private void gridView1_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e)
    {
        MessageBox.Show("unbound column a go go");
  1. 如何填充未绑定列?

感谢 DevExpress 支持论坛解决了(顺便说一下,这非常好)

我错过了 gridView1.CustomUnboundColumnData += gridView1_CustomUnboundColumnData; 的行,该行告诉网格将哪个事件处理程序用于未绑定的列