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

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

问题描述

我想在DataGrid中选定单元格的值,请任何人告诉如何做到这一点。我用SelectedCell更改事件,我该怎么办呢?



  dataGrid1.CurrentCell 


解决方案

请参阅的DataGrid类页面上MSDN。从该页面:




选择



通过默认情况下,当用户点击在数据网格中的细胞被选择整行,并且用户可以选择多行。您可以设置的SelectionMode 属性来指定用户是否能够选择细胞,全行,或两者兼而有之。将SelectionUnit属性来指定是否多行或单元格可以选择,或只有单行或单元格。



您可以获取有关选自细胞信息< A HREF =htt​​p://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid.selectedcells.aspx>了selectedCells 属性。为此选择在 SelectedCellsChangedEventArgs 的SelectedCellsChanged事件。调用SelectAllCells或UnselectAllCells方法以编程方式选择或取消选择所有单元格。欲了解更多信息,请参阅DataGrid控件的默认键盘和鼠标行为。




我添加链接为您的相关性,但我出来的时候了,所以我希望你能按照链接,让您的解决方案。


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

解决方案

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

Selection

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.

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天全站免登陆