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