Getting hold of parent cell/row of Control in DataGridView

0
0

Hi guys,

Using the new DataGridViewCell.Control property, I added some buttons in specific cells of a datagridview in the databindingcomplete event.

Now, when one of those buttons is clicked, how can I get hold of its parent cell or row? The Parent property is null. Am I missing something?

Best,

Alex

  • You must to post comments
0
0

You could also add the cell to the Buttons tag property.

  • You must to post comments
0
0

Hi Frank,

That was fast! 🙂 Thanks!

I think the way to follow is UserData. I don’t see how to use CurrentCell in the Button_Click event. The CellClicked event does not seem to fire when I click on the button contained in the cell.

Best,
Alex

  • You must to post comments
0
0

Hi Alex,

You can either use the CurrentCell.RowIndex property or store a reference in UserData.

Please take a look at the simple sample attached. It uses both techniques.

Hope that helps.

Best regards
Frank

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.