Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > About DataGridView
 

About DataGridView

How to get rowindex in selectionchanged event of datagridview
  • Moved byeryangMSFTFriday, September 11, 2009 7:03 AM (From:.NET Base Class Library)
  •  
NewProgammer  Tuesday, September 08, 2009 10:19 AM
Use the following code: dataGridView1.CurrentRow.Index
Jahedur.Rahman  Tuesday, September 08, 2009 11:33 AM

Hi,

If you want to get all the selected row index, you can use the following code:

void dataGridView1_SelectionChanged(object sender, EventArgs e)

{

foreach(DataGridViewRow r in dataGridView1.SelectedRows)

{

Console.WriteLine(r.Index.ToString()); //get the row index

}

Console.WriteLine();

}

Best regards,

Ling Wang


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Tuesday, September 15, 2009 3:22 AM
Use the following code: dataGridView1.CurrentRow.Index
Jahedur.Rahman  Tuesday, September 08, 2009 11:33 AM

Hi,

If you want to get all the selected row index, you can use the following code:

void dataGridView1_SelectionChanged(object sender, EventArgs e)

{

foreach(DataGridViewRow r in dataGridView1.SelectedRows)

{

Console.WriteLine(r.Index.ToString()); //get the row index

}

Console.WriteLine();

}

Best regards,

Ling Wang


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Tuesday, September 15, 2009 3:22 AM

You can use google to search for other answers

Custom Search

More Threads

• Bind file to Grid
• datagrid with checkboxes
• SavePoints in Transactions
• Stop DataGridView from Resetting
• Disable TEXT in the TEXTBOX Not the TEXTBOX
• datagridview combobox selected index
• datagrid combobox question relating to predefining items in a column
• I have problem with datagridviewcombobox column
• somebody plz help
• how to select all items in a list box