currentFirstVisibleRowIndex >= 0 && currentFirstVisibleRowIndex < dataGridView2.Rows.Count

1114
nodyang@aliyun.com 5 days ago
parent 3432ece505
commit 61c30d2bd7

@ -76,7 +76,7 @@ namespace RfidWeb.Frm
{ {
int currentFirstVisibleRowIndex = dataGridView1.FirstDisplayedScrollingRowIndex; int currentFirstVisibleRowIndex = dataGridView1.FirstDisplayedScrollingRowIndex;
this.dataGridView1.DataSource = lsList; this.dataGridView1.DataSource = lsList;
if (currentFirstVisibleRowIndex > 0) if (currentFirstVisibleRowIndex >=0 && currentFirstVisibleRowIndex < dataGridView1.Rows.Count)
{ {
dataGridView1.FirstDisplayedScrollingRowIndex = currentFirstVisibleRowIndex; dataGridView1.FirstDisplayedScrollingRowIndex = currentFirstVisibleRowIndex;
} }
@ -101,7 +101,7 @@ namespace RfidWeb.Frm
{ {
int currentFirstVisibleRowIndex = dataGridView2.FirstDisplayedScrollingRowIndex; int currentFirstVisibleRowIndex = dataGridView2.FirstDisplayedScrollingRowIndex;
this.dataGridView2.DataSource = lsList; this.dataGridView2.DataSource = lsList;
if (currentFirstVisibleRowIndex > 0) if (currentFirstVisibleRowIndex >= 0 && currentFirstVisibleRowIndex < dataGridView2.Rows.Count)
{ {
dataGridView2.FirstDisplayedScrollingRowIndex = currentFirstVisibleRowIndex; dataGridView2.FirstDisplayedScrollingRowIndex = currentFirstVisibleRowIndex;
} }

Loading…
Cancel
Save