473,770 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.BeginU pdate();

listView.Items. Clear();

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

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

listView.EndUpd ate();
}

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 6387
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.BeginU pdate();

listView.Items. Clear();

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

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

listView.EndUpd ate();
}

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>.Painti ng = False ... do stuff ... <form>.Painin g = 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>.Painti ng = False ... do stuff ... <form>.Painin g = True.


Yeah, that's what ListView.BeingU pdate() and ListView.EndUpd ate() do
here. .NET can be very VCL-ish.
Nov 15 '05 #3
First I've added microsoft.publi c.dotnet.framew ork.windowsform s.controls
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******** ******@tk2msftn gp13.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.BeginU pdate();

listView.Items. Clear();

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

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

listView.EndUpd ate();
}

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******** ******@tk2msftn gp13.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.BeginU pdate();

listView.Items. Clear();

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

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

listView.EndUpd ate();
}

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.publi c.dotnet.framew ork.windowsform s.controls
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.co m>
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
2637
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 am populating listview with more than 200,000 items. It is too slow and tried virtual listview. But that doesnot allow me to add images in the listview. So now trying to list only the page user scrolls to.
0
489
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 am populating listview with more than 200,000 items. It is too slow and tried virtual listview. But that doesnot allow me to add images in the listview. So now trying to list only the page user scrolls to.
6
4659
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(); listView1.Items.Add (myString); } Is there a way I can fill up the second column this easily? Thw way I'm currently doing it is using the subitems property to add it. Unfortunately,
0
2231
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 ("Col1",200,HorizontalAlignment.Left); listview.Columns.Add ("Col2",800,HorizontalAlignment.Left);
7
6449
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 ListView.Items.Add(), . I see that it is a virtual method so it should be easy to do. If anyone can help I would appreciate it greatly. I can do what I need to do in a different way this would just make everything significantly cleaner and eaasier...
7
15004
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 MyList data is resident in a dataset table. I'm stuck and can't choose either because. If I choose ListView as my control I don't understand how to programmatically get the data from the dataset table
2
4094
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 ensurevisible, ie the listview shows a maximum of 6 items and if I want to scroll down one I use the code... listview.ensurevisible(listview.TopItem.Index + 6)
2
6831
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 form every thing works fine: checking items by code
4
4516
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 is that when clicking on the "Show details" button the ListView for the appropriate row binds in the codebehind and displays the detail data for the selected row. I did something similar with a gridview control previously, but want to be able to...
0
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10260
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9910
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.