1
我不確定這是否可能,但我想獲取DataGridView單元格內的按鈕的實例。 (使用c#.net和windows窗體)如何獲取DataGridView單元格內的按鈕的實例?
原因是因爲我想彈出一個控制面板靠近那個按鈕,所以我需要它的位置。 (這可能嗎?)。
我處理按鈕的點擊在CellClicked事件處理程序:
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
Int32 id = (Int32)dataGridView1[0, e.RowIndex].Value;
if (e.RowIndex < 0 || e.ColumnIndex != dataGridView1.Columns["NewDate"].Index)
{
if (e.RowIndex < 0 || e.ColumnIndex != dataGridView1.Columns["Delete"].Index) return;
else
{
}
}
else
{
//Button button - the button I'm trying to get
panel2.Location=new Point(button.Location.X,button.Location.Y);
}
}
你檢查了答案嗎? –