开发者

C#: Getting a button to display a preset form

开发者 https://www.devze.com 2022-12-10 05:46 出处:网络
I (currently) have two forms, one that needs to call the other.开发者_运维百科 In other words, by clicking a certain button in Form1, Form2 needs to \"pop up\", like a dialog box. I know I have to get

I (currently) have two forms, one that needs to call the other.开发者_运维百科 In other words, by clicking a certain button in Form1, Form2 needs to "pop up", like a dialog box. I know I have to get a reference in both forms, but I'm not entirely sure how to do this. What is a decent tutorial/beginner site to learn about GUIs in C#?


You can try this:

protected void Button1_Click(object sender, EventArgs e)
{
    Form2 myForm = new Form2();
    myForm.ShowDialog();
}

ShowDialog forces the user to close that window before s/he can access the rest of the application.

0

精彩评论

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

关注公众号