C
C# Learner
Here's a simple way to recreate my flicker problem.
- Create a new project.
- Put a ListBox on the form.
- Resize it so that it can accompany 20 items.
- Put a button on the form.
- Double-click the button to add a Click event handler.
- Insert the following code in the event handler:
{
TestListBox();
}
- Create a new method by inserting the following code:
private void TestListBox()
{
listBox1.BeginUpdate();
listBox1.Items.Clear();
for (int i = 0; i < 20; ++i) {
listBox1.Items.Add("test");
}
listBox1.EndUpdate();
}
- Run the app and click the button, to see, in my case, items being
added with a horrible flicker effect
- Create a new project.
- Put a ListBox on the form.
- Resize it so that it can accompany 20 items.
- Put a button on the form.
- Double-click the button to add a Click event handler.
- Insert the following code in the event handler:
{
TestListBox();
}
- Create a new method by inserting the following code:
private void TestListBox()
{
listBox1.BeginUpdate();
listBox1.Items.Clear();
for (int i = 0; i < 20; ++i) {
listBox1.Items.Add("test");
}
listBox1.EndUpdate();
}
- Run the app and click the button, to see, in my case, items being
added with a horrible flicker effect
