From ea4d400eabc974972fefc2d0f28a4f620c148590 Mon Sep 17 00:00:00 2001 From: "nodyang@aliyun.com" Date: Mon, 18 Nov 2024 17:37:08 +0800 Subject: [PATCH] demo --- RfidWeb/Frm/UserAlarmShow.cs | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/RfidWeb/Frm/UserAlarmShow.cs b/RfidWeb/Frm/UserAlarmShow.cs index fa85f21..b3da3b1 100644 --- a/RfidWeb/Frm/UserAlarmShow.cs +++ b/RfidWeb/Frm/UserAlarmShow.cs @@ -74,11 +74,19 @@ namespace RfidWeb.Frm } this.Invoke(() => { - int currentFirstVisibleRowIndex = dataGridView1.FirstDisplayedScrollingRowIndex; - this.dataGridView1.DataSource = lsList; - if (currentFirstVisibleRowIndex >=0 && currentFirstVisibleRowIndex < dataGridView1.Rows.Count) + try { - dataGridView1.FirstDisplayedScrollingRowIndex = currentFirstVisibleRowIndex; + int currentFirstVisibleRowIndex = dataGridView1.FirstDisplayedScrollingRowIndex; + this.dataGridView1.DataSource = lsList; + if (currentFirstVisibleRowIndex >= 0 && currentFirstVisibleRowIndex < dataGridView1.Rows.Count) + { + dataGridView1.FirstDisplayedScrollingRowIndex = currentFirstVisibleRowIndex; + } + } + catch (Exception e) + { + Console.WriteLine(e); + } }); } @@ -99,11 +107,18 @@ namespace RfidWeb.Frm } this.Invoke(() => { - int currentFirstVisibleRowIndex = dataGridView2.FirstDisplayedScrollingRowIndex; - this.dataGridView2.DataSource = lsList; - if (currentFirstVisibleRowIndex >= 0 && currentFirstVisibleRowIndex < dataGridView2.Rows.Count) + try + { + int currentFirstVisibleRowIndex = dataGridView2.FirstDisplayedScrollingRowIndex; + this.dataGridView2.DataSource = lsList; + if (currentFirstVisibleRowIndex >= 0 && currentFirstVisibleRowIndex < dataGridView2.Rows.Count) + { + dataGridView2.FirstDisplayedScrollingRowIndex = currentFirstVisibleRowIndex; + } + } + catch (Exception e) { - dataGridView2.FirstDisplayedScrollingRowIndex = currentFirstVisibleRowIndex; + Console.WriteLine(e.Message); } }); }