WPF DataGrid - 以编程方式将单元格设置为编辑模式 [英] WPF DataGrid - Set a cell into edit mode programmatically

查看:68
本文介绍了WPF DataGrid - 以编程方式将单元格设置为编辑模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 我有一个 WPF DataGrid 显示一些数据记录(绑定到 ObservableCollection).

  • I have a WPF DataGrid that shows some data records (bounded to an ObservableCollection).

当用户点击编辑"按钮时,当前选中的行应该进入编辑模式(就像用户双击该行一样).

When the user clicks "Edit" button, the currend selected row should move into edit-mode (As if the user double-clicked this row).

我该怎么做?

推荐答案

假设 WPF:

<DataGrid x:Name="dg".... />

然后此代码将起作用:

dg.CurrentCell = new DataGridCellInfo(dg.Items[i], dg.Columns[j]);
dg.BeginEdit();

这篇关于WPF DataGrid - 以编程方式将单元格设置为编辑模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆