开发者

Update List item from DataGrid event CellEditEnding

开发者 https://www.devze.com 2023-04-13 00:15 出处:网络
I\'ve loaded datagrid from a LIST. On every click event to a button it loads data to the LIST and eventually update the DataGrid by resetting the source.

I've loaded datagrid from a LIST. On every click event to a button it loads data to the LIST and eventually update the DataGrid by resetting the source.

Next thing I would like to do is to edit the values in Cell of that DataGrid and add it back to the List.

I've used struct to add data to List Items and DataGrid. This is the struct:

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

Here开发者_如何学编程 is a code for CellEditEnding event.

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}

Help me out...


Your problem is still not clear to me but use DataGridCellEditEndingEventArgs in the CellEditEnding Event to gt the required values........ this link for Properties that might help you.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号