DataGridView vertical scrollbar not updating properly (Forms bug?)

后端 未结 14 1928
伪装坚强ぢ
伪装坚强ぢ 2021-01-03 23:49

I\'ve encountered a bug (I assume) in .NET 3.5. When adding rows to a DataGridView using Rows.Add(), while the DGV is disabled, the vertical scrollbar doesn\'t update proper

14条回答
  •  庸人自扰
    2021-01-04 00:08

    My problem stemmed from calling dgv.Add() in a user thread. After changing it to be called from the UI thread instead, the scroll bar displayed and functioned normally:

            if (dataGridView1.InvokeRequired)
            {
                dataGridView1.Invoke((Action)(() => dataGridView1.Rows.Add(new String[] { abc, efg })));
            }
            else
            {
                dataGridView1.Rows.Add(new String[] { calPoint, logUrl });
            }
    

提交回复
热议问题