如何获取多个单元格内容并将其存储在字符串中 [英] how to get multiple cell content and store it in a string

查看:66
本文介绍了如何获取多个单元格内容并将其存储在字符串中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用数据网格,并且将SelectionMode属性设置为多个单元格"
和数据网格具有7列的1000条记录.
我只想只在DataGrid中选择的单元格中将单元格中的内容存储在字符串中?

在Advance中致谢

Hi,
I am using a datagrid and I set to the SelectionMode property to "multiple cells"
and data grid has 1000 records with 7 columns.
I just want to store the contents of the cells in the string from only the cells that I selected in the DataGrid how to accomplish this task?

Thanks in Advance

推荐答案

您可以使用DataGridColumn的DataGrid.SelectedCells属性和GetCellContent方法获取选定的单元格值.例如:

You can get the selected cells values using the DataGrid.SelectedCells property and GetCellContent method of the DataGridColumn. For example:

for (int i = 0; i < this.datagrid.SelectedCells.Count; i++)
 {
      Console.WriteLine((this.datagrid.SelectedCells[i].Column.GetCellContent 
     (this.datagrid.SelectedCells[i].Item) as TextBlock).Text);
 }



希望这会有所帮助.



Hope this helps.


这篇关于如何获取多个单元格内容并将其存储在字符串中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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