我已经做了几天,这让我发疯。我有一个继承自System.Windows.Forms.Panel的控件,我正在尝试覆盖OnPaint方法。但它完全无视了我的操作。
public class CollapsiblePanel : System.Windows.Forms.Panel
{
public CollapsiblePanel()
{
//
// Required for the Windows Form Designer
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
SetStyle
(
ControlStyles.AllPaintingInWmPaint |
ControlStyles.UserPaint | ControlStyles.DoubleBuffer |
ControlStyles.ResizeRedraw | ControlStyles.Selectable ,
true
);
}
protected override void OnPaint(PaintEventArgs e)
{
// This never runs no matter what I try!
base.OnPaint(e);
}
}