WPF Datagrid 获取选定的单元格值 [英] WPF Datagrid Get Selected Cell Value

查看:83
本文介绍了WPF Datagrid 获取选定的单元格值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取 datagrid 中选定单元格的值,请告诉任何人如何执行此操作.我使用了 SelectedCell 更改事件,我该怎么做?

I want to get value for selected cell in datagrid , please anyone tell how to do this. i used SelectedCell changed event , how can i do that?

dataGrid1.CurrentCell

推荐答案

请参考 DataGrid Class 页面在 MSDN 上.从该页面:

Please refer to the DataGrid Class page on MSDN. From that page:

选择

默认情况下,当用户单击 DataGrid 中的单元格时,会选择整行,并且用户可以选择多行.您可以将 SelectionMode 属性设置为指定用户是否可以选择单元格、整行或两者.设置 SelectionUnit 属性以指定是可以选择多行或单元格,还是只能选择单行或单元格.

By default, the entire row is selected when a user clicks a cell in a DataGrid, and a user can select multiple rows. You can set the SelectionMode property to specify whether a user can select cells, full rows, or both. Set the SelectionUnit property to specify whether multiple rows or cells can be selected, or only single rows or cells.

您可以获取有关从 SelectedCells 属性.您可以在 中获取有关选择已更改的单元格的信息SelectedCellsChangedEventArgs 的 SelectedCellsChanged 事件.调用 SelectAllCells 或 UnselectAllCells 方法以编程方式选择或取消选择所有单元格.有关详细信息,请参阅 DataGrid 控件中的默认键盘和鼠标行为.

You can get information about the cells that are selected from the SelectedCells property. You can get information about cells for which selection has changed in the SelectedCellsChangedEventArgs of the SelectedCellsChanged event. Call the SelectAllCells or UnselectAllCells methods to programmatically select or unselect all cells. For more information, see Default Keyboard and Mouse Behavior in the DataGrid Control.

我已经为您添加了相关属性的链接,但我现在没时间了,所以我希望您可以按照链接找到您的解决方案.

I have added links to the relevant properties for you, but I'm out of time now, so I hope you can follow the links to get your solution.

这篇关于WPF Datagrid 获取选定的单元格值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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