From 61c30d2bd738d6489500b56bb57440d404fe735e Mon Sep 17 00:00:00 2001 From: "nodyang@aliyun.com" Date: Mon, 18 Nov 2024 17:35:37 +0800 Subject: [PATCH] currentFirstVisibleRowIndex >= 0 && currentFirstVisibleRowIndex < dataGridView2.Rows.Count --- RfidWeb/Frm/UserAlarmShow.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RfidWeb/Frm/UserAlarmShow.cs b/RfidWeb/Frm/UserAlarmShow.cs index c1a653f..fa85f21 100644 --- a/RfidWeb/Frm/UserAlarmShow.cs +++ b/RfidWeb/Frm/UserAlarmShow.cs @@ -76,7 +76,7 @@ namespace RfidWeb.Frm { int currentFirstVisibleRowIndex = dataGridView1.FirstDisplayedScrollingRowIndex; this.dataGridView1.DataSource = lsList; - if (currentFirstVisibleRowIndex > 0) + if (currentFirstVisibleRowIndex >=0 && currentFirstVisibleRowIndex < dataGridView1.Rows.Count) { dataGridView1.FirstDisplayedScrollingRowIndex = currentFirstVisibleRowIndex; } @@ -101,7 +101,7 @@ namespace RfidWeb.Frm { int currentFirstVisibleRowIndex = dataGridView2.FirstDisplayedScrollingRowIndex; this.dataGridView2.DataSource = lsList; - if (currentFirstVisibleRowIndex > 0) + if (currentFirstVisibleRowIndex >= 0 && currentFirstVisibleRowIndex < dataGridView2.Rows.Count) { dataGridView2.FirstDisplayedScrollingRowIndex = currentFirstVisibleRowIndex; }