0

我有一个自定义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相应地调整大小,以使它们保持不变。

4

2 回答 2

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;
    }
}
于 2013-10-02T11:02:44.510 回答
0
this.OnSizeChanged(new EventArgs());
于 2013-10-02T10:58:30.230 回答