これは、 DataGridViewButtonColumnの MSDN ページで回答されています。
DataGridView の CellClick または CellContentClick イベントを処理する必要があります。
ハンドラーをアタッチするには:
dataGridView1.CellClick += new DataGridViewCellEventHandler(dataGridView1_CellClick);
そして、イベントを処理するメソッドのコード
void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
// Check that the button column was clicked
if (dataGridView1.Columns[e.ColumnIndex].Name == "MyButtonColumn")
{
// Here you call your method that deals with the row values
// you can use e.RowIndex to find the row
// I also use the row's databounditem property to get the bound
// object from the DataGridView's datasource - this only works with
// a datasource for the control but 99% of the time you should use
// a datasource with this control
object item = dataGridView1.Rows[e.RowIndex].DataBoundItem;
// I'm also just leaving item as type object but since you control the form
// you can usually safely cast to a specific object here.
YourMethod(item);
}
}