我已从 扩展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);
}
}
但是,当我添加 anew TextBox();
时,Form
它仍然继承自 Control 而不是Ctrl
. 如何使所有新控件继承自Ctrl
?