如何在用户完成编辑行后获取DataGrid行数据?

时间:2011-01-12 21:03:51

标签: c# wpf wpf-controls wpfdatagrid

我想在用户在数据网格中输入一行后立即验证用户输入的内容。

我应该查看什么事件,以及如何检索行数据?或者甚至更好,它必然会受到什么目标?

3 个答案:

答案 0 :(得分:10)

使用RowEditEnding事件。

private void DataGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
{
  YourObject obj = e.Row.Item as YourObject;
  if (obj != null)
  {
     //see obj properties
  }
}

答案 1 :(得分:3)

  1. 事件RowEditEnding
  2. 数据应位于e.Row.DataContext / e.Row.Item

答案 2 :(得分:0)

如果您遇到问题,我可以成功使用:

SELECT MAX('id') FROM user_feed WHERE user_id = :(id of the user whose feed    
        is changing)