When a column button is clicked I wonder how I can get that data for that particular row.
For instance below I would like to get the data for the object of Puppypuppy and pass on the data to a UserControl (which in my case is a simple window that I want to populate with the data from the clicked button)
The code for the event when a button is clicked:
- private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
- {
- var senderGrid = (DataGridView)sender;
- if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
- e.RowIndex >= 0)
- {
- // How to get the data of an object when a column button is clicked and pass it to a user control?
- // UserControlPlayAnimal playAnimals = new UserControlPlayAnimal();
- }
- }

Yogeshkumar HadiyaRank #358 · 7K reputationPosted Feb 10, 2021, 11:32 PM EST
Chris Anderson137 reputationPosted Feb 11, 2021, 12:03 PM EST
Chris Anderson137 reputationPosted Feb 11, 2021, 12:28 PM EST