myesn

myEsn2E9

hi
github

[To be organized] Windows Forms Key Points

In general, only the thread that creates the control can access the control, otherwise it may cause deadlocks, resource competition, suspension, or pause issues. Cross-thread access to UI controls should be done in a thread-safe manner, Microsoft has introduced two ways: How to make thread-safe calls to controls (Windows Forms .NET).

Flickering issue when scrolling DataGridView: How to prevent DataGridView from flickering when scrolling horizontally? - Stack Overflow.

Frequent use of Refresh() in DataGridView can cause the right scroll bar to become black and unusable, in this case, relying on Refresh() to redraw the control is not feasible, you can rebind the DataSource:

// Access UI controls across threads in a thread-safe manner
dataGridView1.Invoke(() =>
{
    dataGridView1.DataSource = null;
    dataGridView1.DataSource = _dataTable;
});
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.