1

假设我有一个 Janus 网格,它有两列,并且行按层次顺序组织,即父行和子行。网格中的一列被分组(通过拖动网格上方的分组依据框中的列)。我有一个单元格更改事件,当单元格内容更改时会触发该事件。我在单元格更改事件中执行此操作:

Dim grid as GridEx = e.Column.GridEx 'e is of type ColumnActionEventArgs
Dim value as Object = grid.GetValue(e.Column)
Dim row as GridEXRow = grid.GetRow 'This is the parent row which has 2 child rows for example
...
Dim drCurrent As DataRow = CType(row.DataRow(), DataRowView).Row
drCurrent.Item(e.Column.DataMember) = value 'set the parent row column value

如果我在父行中更改分组列的值,则子行设置为Nothing. 在上述代码段的最后一行之后,子行row设置为Nothing. 另一方面,如果我更改另一列的值(不在分组依据框中),则不会发生此问题。仅当我对列进行分组并且不更改其值时才会出现问题。知道为什么会这样吗?

4

1 回答 1

1

您提供的代码示例...

您在哪个网格事件中有此代码?CellValueChanged 或 CellEdited 或其他?

您可能想尝试这 3 行,而不是代码示例中的最后一行:

   row.BeginEdit()
   drCurrent.Item(e.Column.DataMember) = value 'set the parent row column value
   row.EndEdit()

如果这没有帮助,请提供有关您正在使用的其他网格事件的更多信息。

于 2012-05-14T21:20:21.877 回答