accessing protected members of inherited classes

J

JH

I am attempting to enable double buffering for a panel
control. The SetStyle method of the panel control is
protected, so I am attempting to access it by writing a
special panel class that inherits from
System.Windows.Forms.Panel.

But from there I am not sure how to access the protected
member SetStyle to set DoubleBuffer to true. Can anyone
point me in the right direction? Some code example would
be extremely helpful to me.

Thanks

JH
 
I

Ignacio Machin

All you have to do is derive your class from Panel:

class SpecialPanel: System.Windows.Forms.Panel
{
}

from MSDN Control.SetStyle:

public void EnableDoubleBuffering()
{
// Set the value of the double-buffering style bits to true.
this.SetStyle(ControlStyles.DoubleBuffer |
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint,
true);
this.UpdateStyles();
}


Hope this help,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top