Re-Creating the Problem

  • Thread starter Thread starter C# Learner
  • Start date Start date
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 :(
 
Your first post said "ListView" now you say "ListBox" Does this mean you are
seeing this on both controls?

Not that I'm calling you a liar, but I don't see a problem.

Whether I add 20 or 2000 to either control, not only do I not see any
flicker but the items appear all at one time. And I see no difference if I
use BeginUpdate/EndUpdate or not.

This is on my 1Ghz desktop, and my 650Mhz laptop.

What about sorting, do you have Sorting turned on? This has been known to
cause the flicker you describe. Before adding your items turn sorting off
then after your items are added turn it back on.


Regards
Brian W
 
Brian said:
Your first post said "ListView" now you say "ListBox" Does this mean you are
seeing this on both controls?

Yes. It's slightly worse with ListView, but flickering also happens
with ListBox.
Not that I'm calling you a liar, but I don't see a problem.

Whether I add 20 or 2000 to either control, not only do I not see any
flicker but the items appear all at one time. And I see no difference if I
use BeginUpdate/EndUpdate or not.

This is on my 1Ghz desktop, and my 650Mhz laptop.

What about sorting, do you have Sorting turned on? This has been known to
cause the flicker you describe. Before adding your items turn sorting off
then after your items are added turn it back on.

No - it's not turned on. Following the exact steps in my original post
causes flickering here.
 
C# Learner wrote:

No - it's not turned on. Following the exact steps in my original post
causes flickering here.

It seems that the controls (ListBox or ListView) are struggling to
/draw/ the items. The thing is, this only happens with .NET controls.
 
C# Learner said:
It seems that the controls (ListBox or ListView) are struggling to
/draw/ the items. The thing is, this only happens with .NET controls.

You mentioned in one of your other posts that you're using a "64MB video
card", but not which kind. Is it a modern card, good drivers, etc.? This
sounds like either a severe lack of RAM in the machine or a poorly
implemented video card driver. However it seems odd that it would only
affect .NET controls, when they use the underlying Windows controls to
do most of their work.
 
Kevin P. Fleming said:
C# Learner wrote:

However it seems odd that it would only
affect .NET controls, when they use the underlying Windows controls to
do most of their work.

Agreed. The .NET Framework is only a thin wrapper to the windows controls.
Much the same way CListBox, in MFC, is a thin wrapper to listbox windows
control.

Regards
Brian W
 
C# Learner said:
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 :(

Hi -

I followed your directions to the letter and no flicker here with 20 or
200,000 items. AMD Athlon Thunderbird 900MHz + 1.5GB RAM. Is the problem
consistent across all machines you run the code on?
 
Abhishek said:
Could you try this example on any other machine as well? preferably one
different type of graphics card?

Trying the example out on many machines will help you narrow down
whether the problem is with the h/w of your machine or it is really your
program.

I wish I could, but can't, unfortunately.

Regards
 
C# Learner said:
Here's a simple way to recreate my flicker problem.

At the risk of being off-topic, see if you get the same results with an MFC
application:
create new C++/MFC Application
in Application Type, select Dialog Based
click Finish
add List Box to form, size appropriately
right-click the List Box, select Add Variable
type Variable Name "m_lb"
click Finish
double-click OK button to add code
replace wizard code with this:

m_lb.ResetContent();
for(int i=0;i<20;i++)
m_lb.AddString("test");

compile and run.

Mike
 
Could you try this example on any other machine as well? preferably one
different type of graphics card?

Trying the example out on many machines will help you narrow down
whether the problem is with the h/w of your machine or it is really your
program.

regards,
Abhishek.
 
Back
Top