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

There is matter with my code on DataGridView RemoveAt() SelectedRow

$
0
0

Below code block somehow acts up as removing more than one of DataGridView. It removes two rows of DataGridView usually if not there is one only row main in DGV. What's the matter?

private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Delete)
    {
        Int32 selectedRow = dataGridView1.SelectedRows[0].Index;
        dataGridView1.Rows.RemoveAt(selectedRow);
    }
}


Viewing all articles
Browse latest Browse all 2535

Trending Articles



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