【问题标题】:Update List item from DataGrid event CellEditEnding从 DataGrid 事件 CellEditEnding 更新列表项
【发布时间】:2011-12-08 07:07:16
【问题描述】:

我已从 LIST 加载数据网格。在按钮的每个单击事件上,它都会将数据加载到 LIST 并最终通过重置源来更新 DataGrid。

接下来我想做的是编辑该 DataGrid 的单元格中的值并将其添加回列表。

我使用 struct 将数据添加到 List Items 和 DataGrid。 这是结构:

public struct MyData {
public string item{get;set;}
public int number{get;set;}
}

这是 CellEditEnding 事件的代码。

int index = DataGrid1.SelectedIndex;
// I KNOW PROBLEM IS HERE as it selects the previous value not the changed value.
MyData foo = (MyData)DataGrid1.SelectedItem;
DataGrid1[index] = new MyData{item=foo.item.ToString(), number = 5}

帮帮我...

【问题讨论】:

    标签: c# wpf datagrid arraylist


    【解决方案1】:

    我仍然不清楚您的问题,但请使用 DataGridCellEditEndingEventArgs 在 CellEditEnding 事件中 gt 所需的值........ this 链接可能对您有所帮助的属性。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-02
      • 2016-03-19
      • 1970-01-01
      • 1970-01-01
      • 2015-05-31
      相关资源
      最近更新 更多