我有一个自定义TabPage
类:
class CustomTabPage : TabPage
{
TextBox tbCode = new TextBox();
public CustomTabPage()
{
}
public CustomTabPage(string title)
{
tbCode.Multiline = true;
tbCode.Size = this.Size;
}
//Something like this...
private void OnThisControlSizeChanged()
{
tbCode.Size = this.Size;
}
}
当我从创建控件的位置调整大小时,我需要为此类提升OnSizeChanged
控件的TabPage
事件。这样做的原因是当我调整TabPage
控件的大小时,我想相应地调整TextBox
大小以使它们保持不变。
答案 0 :(得分:1)
class CustomTabPage : TabPage
{
TextBox tbCode = new TextBox();
public CustomTabPage()
{
SizeChanged += CustomTabPage_SizeChanged;
}
void CustomTabPage_SizeChanged(object sender, EventArgs e)
{
OnThisControlSizeChanged();
}
public CustomTabPage(string title)
{
tbCode.Multiline = true;
tbCode.Size = this.Size;
}
private void OnThisControlSizeChanged()
{
tbCode.Size = this.Size;
}
}
答案 1 :(得分:0)
this.OnSizeChanged(new EventArgs());