【发布时间】:2013-08-12 14:52:27
【问题描述】:
我有一个 DataGridViewButtonColumn,但我需要它在单击时做出响应,以便我可以执行代码。有人可以帮忙吗?
【问题讨论】:
-
你能给我们一些代码吗?
标签: .net vb.net events datagrid
我有一个 DataGridViewButtonColumn,但我需要它在单击时做出响应,以便我可以执行代码。有人可以帮忙吗?
【问题讨论】:
标签: .net vb.net events datagrid
如果你想使用 datagridviewcellcontentclick 事件。如果单击按钮单元格,则执行您的逻辑。下面的代码 sn-p 应该会给你一些想法。
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
// find out which column was clicked
if (dataGridView1.Columns[e.ColumnIndex] == Column1)
{
//get the value which you want to display
String customer = (String) dataGridView1.Rows[e.RowIndex].Cells[2].Value;
// display on the new form.
Form form2 = new Form();
form2.Text = customer;
form2.ShowDialog();
}
}
【讨论】: