【问题标题】:How to get string-value of selected cell in datagrid (VS 2008)如何获取数据网格中选定单元格的字符串值(VS 2008)
【发布时间】:2015-03-23 14:37:52
【问题描述】:

如何获取 dataGrid-Control 的 currentCell 的值? 我正在为 Windows CE 使用 VS2008。

我有一个“CurrentCell”元素。 它的 .toString() 方法只获取“windows.forms.datagrid”。 我如何获得价值? 它是一个数据网格,而不是一个数据网格视图!

一些代码:

DataGridCell dc = test_dataGrid.CurrentCell;
string cellValue = dc...

我在 dc 之后用 .toString 尝试过,但得到的只是控件的名称。其他给定的属性是 'rowNumber'、'columnNumber'、'equals'、'getHashCode' 和 'getType'

【问题讨论】:

  • 你试过谷歌搜索吗?互联网上有很多优秀的工作示例,stackoverflow 也有你能展示你实际尝试过的相关代码吗?
  • 我做了,我 95% 的解决方案是针对 dataGridViews 的,另外 5% 是与我类似的问题,答案与 dataGridView 相关。你认为代码对我的问题重要吗?我可以写下我的 dataGrid 的名称。我认为这不会帮助任何人。由于“currentCell”的属性非常少,我认为可能还有其他有用的想法。但我会添加基本代码。
  • CurrentCell.Value?
  • 不可用。那太容易了;)

标签: c# visual-studio-2008 windows-ce


【解决方案1】:

试试这个:

DataGridCell dc = test_dataGrid.CurrentCell;
String cellValue =  test_dataGrid[dc.RowNumber, dc.ColumnNumber].ToString();

基于此 MSDN 链接:

https://msdn.microsoft.com/en-us/library/aa287674(v=vs.71).aspx

【讨论】:

  • 非常感谢! (我之前读过……一定错过了;))
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-28
  • 1970-01-01
  • 2013-08-09
  • 2019-12-31
  • 1970-01-01
  • 2017-11-18
相关资源
最近更新 更多