Getting hold of parent cell/row of Control in DataGridView

Welcome to Wisej Support.
Questions, suggestions and plain old bugs - are all welcome here!
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
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Attachment
File Name Size
There are currently no files uploaded.
Maximum number of files 5, maximum file size 3.9MB.
Supported file formats: zip pdf gif jpg bmp png cs vb theme json