1
HI 如何在DataGridView中获取CurrentCell位置。我需要当我的负载将加载datagridview当前单元格上面设置的每个组合框。并获得相同的大小。我怎样才能做到这一点?如何在DataGridView中获取CurrentCell位置
HI 如何在DataGridView中获取CurrentCell位置。我需要当我的负载将加载datagridview当前单元格上面设置的每个组合框。并获得相同的大小。我怎样才能做到这一点?如何在DataGridView中获取CurrentCell位置
你可以通过使用的CurrentCell
property的ColumnIndex
property包含当前选定单元格的列的从零开始指数:
if (myDataGridView.CurrentCell != null)
{
int columnIndex = myDataGridView.CurrentCell.ColumnIndex;
}
或者,你可以得到列对象本身包含当前选定的单元格通过使用OwningColumn
property:
if (myDataGridView.CurrentCell != null)
{
DataGridViewColumn columnObject = myDataGridView.CurrentCell.OwningColumn;
}
请注意,我仍然不完全确定这是否是您要求的。我的表格没有列,所以我假设你的意思是DataGridView
。你的答案仍然不能真正解释你的“位置”究竟是什么意思,但是这应该告诉你关于包含当前单元格的列的所有知识。
你的意思是*位置*?行号和列号? – 2010-11-28 11:59:49