accessing protected members of inherited classes

  • Thread starter Thread starter JH
  • Start date Start date
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
 
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,
 
Back
Top