473,403 Members | 2,222 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,403 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 7893
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.