Link to home
Start Free TrialLog in
Avatar of Elmo Erasmus
Elmo ErasmusFlag for Namibia

asked on

Click event for button in DataGridViewButtonColumn

Hi

I've got  a DataGridView on a windows form with various columns added by the Data Source. I also added a DataGridViewButtonColumn. The problem I'm having is that I have no idea how to add code to these buttons. Pls Help

Thanks

Elmo
Avatar of gladiatorno9
gladiatorno9

To handle the “button click,” you need to handle the CellClick event on the grid, determine if it was a button cell that was clicked, and then take the appropriate action for your application. This involves taking the event argument from the CellClick event, checking its ColumnIndex property against the column index of button columns in your grid, and then calling the button click handling code from there based on the row index, or the contents of that cell or others in that row.


Avatar of Elmo Erasmus

ASKER

Can you perhaps help me with a bit of sample code?
Thanks
ASKER CERTIFIED SOLUTION
Avatar of gladiatorno9
gladiatorno9

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you very much!
Thank you!