animekun
animekun

Reputation: 1869

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);

Upvotes: 4

Views: 4267

Answers (2)

King King
King King

Reputation: 63317

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);

Upvotes: 8

Bobi
Bobi

Reputation: 777

This could help too:

dataGridView1.DoubleBuffered(true);

https://msdn.microsoft.com/en-us/library/3t7htc9c(v=vs.110).aspx

Upvotes: 0

Related Questions