473,221 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,221 software developers and data experts.

ListView Unbearable

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
9 6342
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Anushya | last post by:
Hi I am using Listview and inherited listview control overriding WndProc & PreProcessMessage in ListView. I need this to customize listview to display only the page the user scrolls to. Since i...
0
by: Anushya | last post by:
Hi I am using Listview and inherited listview control overriding WndProc & PreProcessMessage in ListView. I need this to customize listview to display only the page the user scrolls to. Since i...
6
by: VM | last post by:
How can I fill up a listview with text file contents? My listview has two columns and the first column fills up with a while loop: while (myString != null) { myString = sr.Readline();...
0
by: keith | last post by:
In a ListView control (two columns), I added a few ListView items. ListView listview=new ListView(); listview.Parent=this; listview.View=View.Details; listview.Columns.Add...
7
by: Dave Y | last post by:
I am a newbie to C# and am having trouble trying to override a ListView property method. I have created a new class derived from the Forms.Listview and I cannot figure out the syntax to override...
7
by: BobAchgill | last post by:
I am trying to decide which of these controls to use to implement letting my user select a full row from MyList. The MyList has several columns which would be nice to sort by at run time. The...
2
by: Ben H | last post by:
Hello all I'm using a listview in my app but I want to scroll the listview programatically as I hate the look of the standard scrollbar. So, the listview is scrolled programatically using...
2
by: Peter | last post by:
Hi, I have a problem with Listview using checkboxes. If i check items by code BEFORE the form is shown the Listview.Items are confused during the ItemChecked Event !!! After showing the...
4
by: Brian Gaze | last post by:
I have created a ListView control and have bound this to a datasource. Within the ItemTemplate of the ListView I have added another ListViewControl which is databound in the code behind. The idea...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.