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