473,786 Members | 2,638 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Se tStyle(ControlS tyles.AllPainti ngInWmPaint |
ControlStyles.O paque, 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 28782
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 DoubleBufferPan el : Panel
{
public DoubleBufferPan el()
{
// Set the value of the double-buffering style bits to true.
this.SetStyle(C ontrolStyles.Do ubleBuffer |
ControlStyles.U serPaint |
ControlStyles.A llPaintingInWmP aint,
true);

this.UpdateStyl es();
}
}

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

For example,

System.Windows. Forms.Panel panel1 becomes DoubleBufferPan el panel1

and

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

hope this helps.

--
Rodger Constandse

<http://www.SequenceDia gramEditor.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.Se tStyle(ControlS tyles.AllPainti ngInWmPaint |
ControlStyles.O paque, 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 DoubleBufferPan el : Panel
{
public DoubleBufferPan el()
{
// Set the value of the double-buffering style bits to true.
this.SetStyle(C ontrolStyles.Do ubleBuffer |
ControlStyles.U serPaint |
ControlStyles.A llPaintingInWmP aint,
true);

this.UpdateStyl es();
}
}

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

For example,

System.Windows. Forms.Panel panel1 becomes DoubleBufferPan el panel1

and

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

hope this helps.

--
Rodger Constandse

<http://www.SequenceDia gramEditor.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.Se tStyle(ControlS tyles.AllPainti ngInWmPaint |
ControlStyles.O paque, 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
2985
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 tried using myForm.SetStyles(ControlStyles.DoubleBuffer, True) however it has made no impact on the drawing operation. Any clarification would be greatly appreciated -Alex
5
2426
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 MyBase.OnPain(pe). But in my opinion it doesn't seem to be painted on the buffer. Everything works fine, but I think it should work better if my MyBase.OnPaint also painted in my buffer. Am I wrong? And how should I do this? I kind of need to...
2
3463
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 screen flicker a good bit while this happens. I'm using GDI+ and it say in MSDN that double buffering will fix this but it didnt work for me. this.Setstyle(Controlstyles.DoubleBuffer, true ); this.Setstyle(Controlstyles.UserPaint, true );...
2
5612
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 propagated to the groupbox, and since it's a protected method I can't call groupbox.SetStyle(). I've tried deriving a custom class from System.Windows.Forms.GroupBox and calling SetStyle from inside of it's constructor and from a new method. Both...
2
1667
by: Simon Jefferies | last post by:
Hello, How can i perform double buffering on the Paint Event of a panel control. TIA Simon
1
3935
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 property to true. Now, I am owner drawing my list view items, and yes it does flicker a lot...
1
1831
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 double-buffered property for the panel control. My first question: is the double buffering set on the form inherited by the panel control or do I have to do the old fashioned manual double-buffering with the panel? I've noticed that animation I render...
3
5950
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 when i add controls to this panel dyanamically, the double buffering effect is not there, i move all lines connceted to a control when the control is moved , at this time flickering occurs,also when i enable double buffering for a child control...
1
1665
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 control has no real painting of it's own. The main child is a data area, and the two other children are on top of and to the left of the data area, respectively, making a kind of grid view. So when the data area scrolls, the other two are set to...
0
9650
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10164
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9962
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8992
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6748
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.