Question

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!

Was it helpful?

Solution

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top