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

Double buffering with panel control

Hi!

In my application, I have a panel in the middle of the form, which I'll be
using as a drawing panel. I would like to update the drawing panel each time
when it is required, without updating the form as a whole. The following
snippet makes compiler mad :

this.DXPanel.SetStyle(ControlStyles.AllPaintingInW mPaint |
ControlStyles.Opaque, true);

How can I apply double buffering to panel to update it (with its paint
method and
without flickers)?

Please respond in C#. I am new to C# and have no knowledge in VB.

Thanks for all the suggestion.
Regards
Nov 17 '05 #1
2 28722
Hello,

The problem is that the SetStyle method of the Control class is protected, which
is why the compiler is complaining.

It seems that you need to create a new class derived from Panel and set the
control styles in the constructor. Something like:

public class DoubleBufferPanel : Panel
{
public DoubleBufferPanel()
{
// Set the value of the double-buffering style bits to true.
this.SetStyle(ControlStyles.DoubleBuffer |
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint,
true);

this.UpdateStyles();
}
}

You can then use this new class instead of your panel. Just replace the
System.Windows.Forms.Panel declaration with your DoubleBufferPanel where the
panel variable is declared and where the panel is created in InitializeComponent().

For example,

System.Windows.Forms.Panel panel1 becomes DoubleBufferPanel panel1

and

panel1 = new System.Windows.Forms.Panel(); becomes panel1 = new DoubleBufferPanel();

hope this helps.

--
Rodger Constandse

<http://www.SequenceDiagramEditor.com>
Sequence Diagram Editor - A quick and easy way to draw and edit sequence diagrams

Millennium Falcon wrote:
Hi!

In my application, I have a panel in the middle of the form, which I'll be
using as a drawing panel. I would like to update the drawing panel each time
when it is required, without updating the form as a whole. The following
snippet makes compiler mad :

this.DXPanel.SetStyle(ControlStyles.AllPaintingInW mPaint |
ControlStyles.Opaque, true);

How can I apply double buffering to panel to update it (with its paint
method and
without flickers)?

Please respond in C#. I am new to C# and have no knowledge in VB.

Thanks for all the suggestion.
Regards

Nov 17 '05 #2
I thank you very much Rodger. Your reply has resolved my problem.

Best regards

"Rodger Constandse" wrote:
Hello,

The problem is that the SetStyle method of the Control class is protected, which
is why the compiler is complaining.

It seems that you need to create a new class derived from Panel and set the
control styles in the constructor. Something like:

public class DoubleBufferPanel : Panel
{
public DoubleBufferPanel()
{
// Set the value of the double-buffering style bits to true.
this.SetStyle(ControlStyles.DoubleBuffer |
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint,
true);

this.UpdateStyles();
}
}

You can then use this new class instead of your panel. Just replace the
System.Windows.Forms.Panel declaration with your DoubleBufferPanel where the
panel variable is declared and where the panel is created in InitializeComponent().

For example,

System.Windows.Forms.Panel panel1 becomes DoubleBufferPanel panel1

and

panel1 = new System.Windows.Forms.Panel(); becomes panel1 = new DoubleBufferPanel();

hope this helps.

--
Rodger Constandse

<http://www.SequenceDiagramEditor.com>
Sequence Diagram Editor - A quick and easy way to draw and edit sequence diagrams

Millennium Falcon wrote:
Hi!

In my application, I have a panel in the middle of the form, which I'll be
using as a drawing panel. I would like to update the drawing panel each time
when it is required, without updating the form as a whole. The following
snippet makes compiler mad :

this.DXPanel.SetStyle(ControlStyles.AllPaintingInW mPaint |
ControlStyles.Opaque, true);

How can I apply double buffering to panel to update it (with its paint
method and
without flickers)?

Please respond in C#. I am new to C# and have no knowledge in VB.

Thanks for all the suggestion.
Regards

Nov 17 '05 #3

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

Similar topics

3
by: Alex Glass | last post by:
I have read plenty about applying double buffering for animation and self drawn forms. Is there a way to apply it to a form with many standard controls on it (textboxes, labels etc) ?? I have...
5
by: DraguVaso | last post by:
Hi, I have my custom Inherited DataGrid. I override the OnPaint-event to speed up things and avoid flikkering using Double Buffering. To draw the normal things of the DataGrid I have to call the...
2
by: Jason | last post by:
I have created a 2d isometric game map using tiles and now I'm trying to move around my map..when i go near the edge of the map I want to redraw the map to show new parts of the map however the...
2
by: Dan Neely | last post by:
My dialog has groupboxes with slow to redraw controls, to improve the appearance I want to doublebuffer it. While I can use SetStyle() in the Dailogs constructor the setting change doesn't get...
2
by: Simon Jefferies | last post by:
Hello, How can i perform double buffering on the Paint Event of a panel control. TIA Simon
1
by: Brian Henry | last post by:
In the documentation for the listview for owner drawn it says this Note To avoid issues with graphics flickering when owner drawing, override the ListView control and set the DoubleBuffered...
1
by: TyBreaker | last post by:
I notice in VB 2005 that I can set a form to be double-buffered just by setting that option to true in the Form properties. I have a panel on that form but there doesn't appear to be a...
3
by: ssoffline | last post by:
hi i have an app in which i can drop objects onto a form and move them, it consists of graphics (lines), i am using double buffering to avoid filckering in the parent control which is a panel,but...
1
by: Rune Jacobsen | last post by:
Hi, I have a question about double buffering, or more specifically, when to apply it. As mentioned in another post, I have a control that basically contains three other controls. This parent...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.