Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My DataGridView blinks when refreshing

If I refresh some data in my datagridview, I lose my focus on selected cells and random text blinks.

Why does this happen? In other apps I don't see this problem, so I can fix this, but how?

I refresh data by this code:

SBind.DataSource = DTable; // SBind is binded my grid.DataSource = SBind
SBind.ResetBindings(false);
like image 741
animekun Avatar asked Sep 04 '25 02:09

animekun


1 Answers

Try this:

SBind.SuspendLayout();
SBind.DataSource = DTable;
SBind.ResetBindings(false);
SBind.ResumeLayout(true);

You can also try enabling the DoubleBuffered of your grid like this:

typeof(Control).GetProperty("DoubleBuffered", BindingFlags.NonPublic | BindingFlags.Instance)
               .SetValue(SBind, true, null);
like image 75
King King Avatar answered Sep 06 '25 16:09

King King