【问题标题】:How to get CurrentCell location in DataGridView如何在 DataGridView 中获取 CurrentCell 位置
【发布时间】:2011-05-16 20:14:24
【问题描述】:

你好 如何在 DataGridView 中获取 CurrentCell 位置。我需要什么时候我的负载将加载上面在 datagridview 当前单元格上设置的每个组合框。并获得相同的尺寸。我该怎么做?

【问题讨论】:

  • 您所说的位置是什么意思?行号和列号?
  • 我的意思是表格上的列位置

标签: c# .net winforms datagridview datagridviewcolumn


【解决方案1】:

您可以使用@的ColumnIndex property获取包含当前选定单元格的列的从零开始的索引 987654322@:

if (myDataGridView.CurrentCell != null)
{
    int columnIndex = myDataGridView.CurrentCell.ColumnIndex;
}

或者,您可以使用OwningColumn property获取包含当前选定单元格的列对象本身

if (myDataGridView.CurrentCell != null)
{
    DataGridViewColumn columnObject = myDataGridView.CurrentCell.OwningColumn;
}

请注意,我仍然不完全确定这是否是您所要求的。我的表单没有列,所以我假设您的意思是DataGridView。而且您的回答仍然不能真正解释“位置”的确切含义,但这应该会告诉您有关包含当前单元格的列的所有信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-09
    • 2021-06-06
    • 1970-01-01
    • 2012-12-01
    • 1970-01-01
    相关资源
    最近更新 更多