By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,510 Members | 1,141 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,510 IT Pros & Developers. It's quick & easy.

ListView Unbearable

P: n/a
Has anyone else noticed ListView's unbearable flickering?

I have a project containing a list-view with the following:
- View: Details
- Columns: 5

The following code causes the list-view to flicker:

private void TestListView()
{
const int Num = 20;
const string Text = "Test";

listView.BeginUpdate();

listView.Items.Clear();

ListViewItem[] items = new ListViewItem[Num];
for (int i = 0; i < items.Length; ++i) {
ListViewItem item = new ListViewItem(Text);
item.SubItems.Add(Text);

items[i] = item;
}
listView.Items.AddRange(items);

listView.EndUpdate();
}

It looks like .NET let me down again; I might have to use another
framework for the project due to this.
Nov 15 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
On Mon, 01 Mar 2004 01:15:31 +0000, C# Learner <cs****@learner.here> wrote:
Has anyone else noticed ListView's unbearable flickering?

I have a project containing a list-view with the following:
- View: Details
- Columns: 5

The following code causes the list-view to flicker:

private void TestListView()
{
const int Num = 20;
const string Text = "Test";

listView.BeginUpdate();

listView.Items.Clear();

ListViewItem[] items = new ListViewItem[Num];
for (int i = 0; i < items.Length; ++i) {
ListViewItem item = new ListViewItem(Text);
item.SubItems.Add(Text);

items[i] = item;
}
listView.Items.AddRange(items);

listView.EndUpdate();
}

It looks like .NET let me down again; I might have to use another
framework for the project due to this.


I'm new to .NET, so I haven't played with that yet, but when I have problems
with flickering in other environments, I can usually find some way to turn
painting off while updating it to get rid of the flickering. In Access, that
would be <form>.Painting = False ... do stuff ... <form>.Paining = True.
Nov 15 '05 #2

P: n/a
Steve Jorgensen wrote:
I'm new to .NET, so I haven't played with that yet, but when I have problems
with flickering in other environments, I can usually find some way to turn
painting off while updating it to get rid of the flickering. In Access, that
would be <form>.Painting = False ... do stuff ... <form>.Paining = True.


Yeah, that's what ListView.BeingUpdate() and ListView.EndUpdate() do
here. .NET can be very VCL-ish.
Nov 15 '05 #3

P: n/a
First I've added microsoft.public.dotnet.framework.windowsforms.con trols
this to thread because it's not a C# issue.

What exactly are you seeing and what exactly are the specs of your this new
PC? I have run your code below and it was lightning fast (Athlon 2600 /
Radeon 9700 Pro) for 20, 50 even 1000 items.

Richard

--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
"C# Learner" <cs****@learner.here> wrote in message
news:Og**************@tk2msftngp13.phx.gbl...
Has anyone else noticed ListView's unbearable flickering?

I have a project containing a list-view with the following:
- View: Details
- Columns: 5

The following code causes the list-view to flicker:

private void TestListView()
{
const int Num = 20;
const string Text = "Test";

listView.BeginUpdate();

listView.Items.Clear();

ListViewItem[] items = new ListViewItem[Num];
for (int i = 0; i < items.Length; ++i) {
ListViewItem item = new ListViewItem(Text);
item.SubItems.Add(Text);

items[i] = item;
}
listView.Items.AddRange(items);

listView.EndUpdate();
}

It looks like .NET let me down again; I might have to use another
framework for the project due to this.

Nov 15 '05 #4

P: n/a
It runs fine here. Does your ListView have any unusual property settings?
How slow is the PC you're trying it on?
Nov 15 '05 #5

P: n/a
ListView will only need to repaint if you make changes on the currently
visible screen or before the current view. By using Clear, you're starting
over with a blank screen. This causes a Paint to be called when you leave
the test method.

To prevent flicker when the update is off screen, it's actually
necessary to NOT use BeginUpdate and EndUpdate, because these cause screen
updates regardless of whether the update was on the current view or not.
That is, if items 1 - 25 are visible and you change or remove items 50-100,
or if you add items below the current view, it's best to not use the
BeginUpdate and EndUpdate. But if you make changes to the current screen,
or above the current screen, it will require an update to the view.

Chris R.

"C# Learner" <cs****@learner.here> wrote in message
news:Og**************@tk2msftngp13.phx.gbl...
Has anyone else noticed ListView's unbearable flickering?

I have a project containing a list-view with the following:
- View: Details
- Columns: 5

The following code causes the list-view to flicker:

private void TestListView()
{
const int Num = 20;
const string Text = "Test";

listView.BeginUpdate();

listView.Items.Clear();

ListViewItem[] items = new ListViewItem[Num];
for (int i = 0; i < items.Length; ++i) {
ListViewItem item = new ListViewItem(Text);
item.SubItems.Add(Text);

items[i] = item;
}
listView.Items.AddRange(items);

listView.EndUpdate();
}

It looks like .NET let me down again; I might have to use another
framework for the project due to this.

Nov 15 '05 #6

P: n/a
Richard A. Lowe wrote:
First I've added microsoft.public.dotnet.framework.windowsforms.con trols
this to thread because it's not a C# issue.

What exactly are you seeing and what exactly are the specs of your this new
PC? I have run your code below and it was lightning fast (Athlon 2600 /
Radeon 9700 Pro) for 20, 50 even 1000 items.
This is the first time I've seen such bad performance of basic controls
on any system.

I'm using:

- Windows XP Home SP1
- 2.5 GHz Intel Celeron
- 256MB RAM
- 64MB graphics card

I'll attempt to describe what I'm seeing.

When I run the code, the items are added to the list *slowly*. I can
actually see a "line" running through the list-view while the items are
being added. During this time, there is awful flicker too.

This happens every time I run the code.

As I say, I've *only* noticed this with .NET apps; I've never seen this
before with Delphi/VC++ apps.

It looks awful. I couldn't ever make a decent GUI app with this :(
Richard

Nov 15 '05 #7

P: n/a
Michael A. Covington wrote:
It runs fine here. Does your ListView have any unusual property settings?
No, only the following non-defaults (apart from size, etc.):

- View: Details
- Columns: 5
How slow is the PC you're trying it on?


The other reply I just sent has details on that.
Nov 15 '05 #8

P: n/a
Chris R wrote:
ListView will only need to repaint if you make changes on the currently
visible screen or before the current view. By using Clear, you're starting
over with a blank screen. This causes a Paint to be called when you leave
the test method.

To prevent flicker when the update is off screen, it's actually
necessary to NOT use BeginUpdate and EndUpdate, because these cause screen
updates regardless of whether the update was on the current view or not.
That is, if items 1 - 25 are visible and you change or remove items 50-100,
or if you add items below the current view, it's best to not use the
BeginUpdate and EndUpdate. But if you make changes to the current screen,
or above the current screen, it will require an update to the view.

Chris R.


I've just tried removing the calls to BeginUpdate() and EndUpdate() and
it makes no difference whatsoever.
Nov 15 '05 #9

P: n/a
C# Learner <cs****@learner.here> wrote:

<snip>
When I run the code, the items are added to the list *slowly*. I can
actually see a "line" running through the list-view while the items are
being added. During this time, there is awful flicker too.

This happens every time I run the code.


I suggest you post a *complete* program then, rather than just one
method, as others aren't seeing the problems you are.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.