简体   繁体   中英

C# windows form application

我试图通过单击一个按钮从一个表单应用程序转到下一个表单应用程序,我该怎么做?

I assume by "go from one form application to the next" you mean you want to invoke another executable (another windows forms app, for example). If that assumption is correct, then you can wire up the OnClick method of the button to do something like this:

System.Diagnostics.Process.Start(@"C:\your_other_app.exe");

You can refer to this msdn link for more info about Process.Start and its different variations.

Try this:

    private void button1_Click(object sender, EventArgs e)
    {
        Form2 f2 = new Form2();
        f2.Show() ;
    }

and make sure that button1's click event is handled:

    this.button1.Click += new System.EventHandler(this.button1_Click);

or

    button1.Click += this.button1_Click;

either in the designer code, or in your Form.load handler, or your form constructor.

You have to make in buttonClick SecondForm's object and then object.ShowDialog() or Show, if you want your second form to be active and not to have right to move to first Form, then use ShowDialog method, other way use Show(). Like this :

private void Button_Click(object sender, EvantArgs e) { SecondForm form = new SecondForm(); form.ShowDialog(); //form.Show(); }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM