473,289 Members | 1,791 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,289 software developers and data experts.

Annoying flickering problem

Hi all,

We have a windows forms application with different controls used
inside, each control has several input items such as textboxes and some

treeviews.. etc.
We have been trying to eliminate flickering issues when loading
different controls or switching to different views with no luck, and
have been trying different suggested methods to get rid of the
flickering such as:
- this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
- this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
- SuspendItemsLayout();
- ResumeItemsLayout();
Unfortunately using the above code in each control or the main form
didn't help too, I'm wondering desperately if there is another way to
fix this annoying problem?
FYI: We are using Visual Studio 2005 / .NET 2.0 running on mainly
Windows XP Professional SP2 on 3GHz multithreaded CPU and 1GB RAM.
Thanks for your help.
Maya

Jun 2 '06 #1
3 7888
Hi Maya,

Flickering is an annoyance and sometimes requires a bit of patience and
investigation to eliminate.

Yes use SuspendLayout() / ResumeLayout() to wrap insertion removal and
change of controls. When you call Resumelayout it does not often need
a true parameter.

Do a code review and check for how often, and necessary calls to
Refresh() Invalidate()/ Update() and PerformLayout() are made.

Check you are not using docking styles and wrestling with them in code
for performing layouts!

If you own the controls you are using - code review these - make sure
they behave in their own right. In any case test them on their own in
a separate simple windows app to understand them properly.

Like you've mentioned use SetStyle - appropriately for your own
controls

this.SetStyle ( System.Windows.Forms.ControlStyles.DoubleBuffer, true
);

this.SetStyle ( System.Windows.Forms.ControlStyles.UserPaint, true );

this.SetStyle (
System.Windows.Forms.ControlStyles.AllPaintingInWm Paint, true );

- If you are doing all the painting and drawing - and If you're doing
the lot then override OnPaint, OnPaintBackground and test not calling
the base methods. You don't want the base to fill the control with a
nice gray background every time you change a pixel!

and I've found:

this.SetStyle ( System.Windows.Forms.ControlStyles.ResizeRedraw , false
);

can be useful.

All the above are not instant cures on their own, but once you have a
clear understanding of the flow of things in your app, they are the
tools and methods to get it right. Hope you cure it quickly.

Jun 2 '06 #2
You have some treeviews in a single form? That might not be a good idea
though.

chanmm

"Maya" <kf****@gmail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
Hi all,

We have a windows forms application with different controls used
inside, each control has several input items such as textboxes and some

treeviews.. etc.
We have been trying to eliminate flickering issues when loading
different controls or switching to different views with no luck, and
have been trying different suggested methods to get rid of the
flickering such as:
- this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
- this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
- SuspendItemsLayout();
- ResumeItemsLayout();
Unfortunately using the above code in each control or the main form
didn't help too, I'm wondering desperately if there is another way to
fix this annoying problem?
FYI: We are using Visual Studio 2005 / .NET 2.0 running on mainly
Windows XP Professional SP2 on 3GHz multithreaded CPU and 1GB RAM.
Thanks for your help.
Maya

Jun 2 '06 #3
Usually this happens because you don't include BeginUpdate and
EndUpdate calls when populating, so whats happening is after every
update, the screen gets repainted. To eliminate that, before your
populate loops put BeginUpdate and after put EndUpdate

so, you should do something like treeview.BeginUpdate () and
treeview.EndUpdate () once you are done
Maya wrote:
Hi all,

We have a windows forms application with different controls used
inside, each control has several input items such as textboxes and some

treeviews.. etc.
We have been trying to eliminate flickering issues when loading
different controls or switching to different views with no luck, and
have been trying different suggested methods to get rid of the
flickering such as:
- this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
- this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
- SuspendItemsLayout();
- ResumeItemsLayout();
Unfortunately using the above code in each control or the main form
didn't help too, I'm wondering desperately if there is another way to
fix this annoying problem?
FYI: We are using Visual Studio 2005 / .NET 2.0 running on mainly
Windows XP Professional SP2 on 3GHz multithreaded CPU and 1GB RAM.
Thanks for your help.
Maya


Jun 2 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John Lee | last post by:
Hi, I have a windows application that uses the listview to display about 50 items in detailed view - 4 columns. The first column is static and other columns will be updated in 100-1000ms - it...
2
by: John Lee | last post by:
Thanks Jay for your response. I tried your code and it still flickering a lot. To demonstrate it, you can grab a listview, create 3 columns - name, value, timestamp, in form_load event to add 50...
8
by: benben | last post by:
I created a form and overrided OnPaint, OnClick and OnResize methods. My OnPaint calls base.OnPaint then repaints the whole screen. The screen flickers a lot! It didn't happen when the app was...
5
by: Jim Hubbard | last post by:
Has anyone seen a fix for the flickering effect you get when resizing a Webbrowser control? It's really irritating and doesn't make for a professional-looking application.
2
by: sasifiqbal | last post by:
Hi, One of my developers are facing an interesting problem regarding UserControl invalidation. The problem is: We have two forms in our application. Form A does nothing except loading of...
6
by: Mark Thompson | last post by:
I have a problem with my Visual Basic .NET 2003 application which I have so far been unable to resolve. I am trying to get an OpenGL control that I have created working properly as a control on...
1
by: sj | last post by:
Flickering Subform! I am developing a Quotation system in Access 03. At entry, users enter data thru' a form with subform. However, the subform keep flicker when I run the system on computer...
1
by: Eamorr | last post by:
Hi guys, You'll see down on the bottom right of this map I have two roll- over images (I haven't got round to doing all the other roll-overs until I get these working!!!) ...
2
by: kulabhishek | last post by:
Hello all. I have developed one user control "Grid" in C# and I am using it in another user control inside one panel. The AutoScroll property for the panel is enabled. When the height or...
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

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.