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();
- }
- }
Chris AndersonPosted Feb 11, 2021, 5:28 PM
Chris AndersonPosted Feb 11, 2021, 5:03 PM
Yogeshkumar HadiyaPosted Feb 11, 2021, 4:32 AM