开发者

Winforms: Why do events fire at design-time?

Why are messages displayed at design-time?

My开发者_StackOverflow code is :

class Class1 : TextBox
{
    public Class1()
    {
        this.Resize += new EventHandler(Class1_Resize);
    }

    void Class1_Resize(object sender, EventArgs e)
    {
        MessageBox.Show("Resize");
    }
}

Pic :

Winforms: Why do events fire at design-time?


Because that's the way the Form designer works. It's actually instantiating your control when it displays it in your form at design-time. Thus when you resize the control in the designer, your code for the message box fires.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜