开发者

Update List item from DataGrid event CellEditEnding

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜