Reputation: 1278
Using WinForms, C# .Net 2.0
I'm adding rows to a non bound DataGridView. I would like to have a DataGridViewButtonColumn in one of the columns that deletes that row when clicked. When I try to add a Click event to the DataGridViewButtonColumn, there does not appear to be a definition for Click.
Can anyone point me to a MSDN article or direct me to the answer?
Thanks!
Upvotes: 3
Views: 11154
Reputation: 103535
The DataGridViewButtonColumn MSDN page has this to say:
To respond to user button clicks, handle the DataGridView.CellClick or DataGridView.CellContentClick event. In the event handler, you can use the DataGridViewCellEventArgs.ColumnIndex property to determine whether the click occurred in the button column. You can use the DataGridViewCellEventArgs.RowIndex property to determine whether the click occurred in a button cell and not on the column header.
Upvotes: 2
Reputation: 22284
The DataGridViewButtonColumn class is a container class for DataGridViewButtonCell objects. Those objects have the click events you're looking for.
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewbuttoncolumn_members.aspx
Upvotes: 2