Ok, basically, I have a datagrid with a button column, and the goal is, to be able to load specific things into a second datagrid depending on which rows button was clicked. But I seem to be completely unable to figure out how to get the row index.

The program is loading all of its data from an XML file, so I am going to have it compare the row index to a row index value in the xml file to know what to display in the second datagridview.

Thanks in advance for any help.

Have you looked at:

DataGridView dgvMyName = new DataGridView();

You need to recognize a click or other event inside of the DGV such as when you release the mouse button:

dgvMyName_MouseUp (object sender, MouseEventArgs e)
{
     // get the current row
     int iSelectedRow;

     iSelectedRow = dgvMyName.CurrentRow.Index;

     // now do something with the selected row.
}

Edited 6 Years Ago by __avd: Added [code] tags.

Thank you VERY much. That is exactly what I was stuck on, and now it seems so simple.

Thanks again.

-Adam

This question has already been answered. Start a new discussion instead.