473,289 Members | 1,952 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.

Flickering when resizing controls...

I have a form with a number of panel controls on it. I have overriden the
paint event (of the panel controls) to provide custom painting. What I have
done is to use the Paint event to paint the background colour of a number of
panel controls to be a gradient colour. This works fine. Is there a better
way??

The problem I have is that when I resize the parent form I get alot of
flickering as the paint events are constantly fired. I have used Double
Buffering where possible but this does not appear to resolve the problem.

Any suggestions for reducing flickering when resizing controls with
overriden Paint events?

Many thanks.
Feb 16 '07 #1
1 2675
If your call is to paint the background of the panel, then you might
consider overridng OnPaintBackground instead of OnPaint. There is also
a style property you can use in the contructor to affect whether
things are redrawn when the control is sized. (But normally, you need
the redrawing to happen to dynamically see your sizing.)

public class MyPanel : Panel
{
public MyPanel()
{
SetStyle(ControlStyles.ResizeRedraw, true);
}

protected override void OnPaintBackground(PaintEventArgs e)
{
// base.OnPaintBackground(e);
using (Brush b = new
System.Drawing.Drawing2D.LinearGradientBrush(new Point(0, 0), new
Point(this.ClientSize.Width, this.ClientSize.Height),
Color.Red, Color.Blue))
{
e.Graphics.FillRectangle(b, this.ClientRectangle);
}

}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
}
}
==============
Clay Burch
Syncfusion, Inc.

Feb 16 '07 #2

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

Similar topics

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...
4
by: vani | last post by:
Hi I am fresher in VC++. I am working on a VC++ Project. I have a serious flickering problem when i am resizing the window. Please help me. vani
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.
5
by: n00b | last post by:
I have some forms with maybe around 30 controls on each and anytime I load these forms different parts of it start flickering though not all of them at once and not the same ones everytime. the...
5
by: jtalbot_vizible | last post by:
I was looking at the code on codeproject to solve my listview flickering issue. All the references to functions in the rest of my post refer to that code. It's available at...
3
by: Maya | last post by:
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...
1
by: James | last post by:
Hi all, I have made a derived Listview which can accept the controls as items in it. Controls that we are using are Buttons in each row and implemented Grouping with the help of controls(label on...
0
by: James | last post by:
Hi all, I have made a derived Listview in C# .net 1.1 framework, which can accept the controls as items in it. Controls that we are using are Buttons in each row and implemented Grouping with...
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...
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"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.