Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

DataGridView Event “RowsAdded” doesn't show the correct RowIndex for the NewRow

$
0
0

When creating a new Row in a DataGridView with help of the command:

dataGridView1.Rows.Add();

it creates a new Row, but the e.RowIndex shows still the Index before the New created row.

privatevoid button1_Click(Object sender,EventArgs e){
       dataGridView1.Rows.Add();}privatevoid dataGridView1_RowsAdded(Object sender,DataGridViewRowsAddedEventArgs e){MessageBox.Show(e.RowCount+";"+ e.RowIndex);}

So in case I have 2 rows I would normaly have RowIndex 0 and 1. But when adding programmatically a new line with ".add()" the event RowsAdded shows that the RowIndex is still 1 instead of 2, which is the new created Row


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>