我已经从Control
进行了扩展,就像这样:
public class Ctrl : Control
{
public Boolean HasBorder { get; set; }
public Boolean ShouldDrawBorder { get; set; }
protected override void OnPaint(PaintEventArgs e)
{
if(CertainConditionIsMet)
{
// Then draw the border(s).
if(this.BorderType == BorderTypes.LeftRight)
{
// Draw left and right borders around this Ctrl.
}
}
base.OnPaint(e);
}
}
但是,当我向 Form
添加一个 new TextBox();
时,它仍然继承自 Control
而不是 Ctrl
。如何使所有新的控件都从 Ctrl
继承而不是 Control
?