473,379 Members | 1,379 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,379 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 28709
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.