Home > front end >  Something similar to form2.cs or another page in winforms visual studio
Something similar to form2.cs or another page in winforms visual studio

Time:01-27

I just started using C# & Visual Studio for creating Windows Forms applications. I want to make another page or form for my application. For example, when someone will click on "show results" button in the form1.cs design, I want it to redirect them to another page or form2 that shows the results. From googling, I have only seen using "new Form2()" in the code and redesigning the whole new form again. Is there no alternative? if not then how big projects handle all these new forms designing and code?

Thanks!

CodePudding user response:

You can refer to the following steps to solve your problem.

First, right-click on your project and choose “Add>New Item”. Create a new Form called dashboard.cs. enter image description hereenter image description here

Second double-click on the button “login” in Form1 and add the code in Form1.cs: enter image description here

private void Btnlogin_Click(object sender, EventArgs e)
    {
        dashboard d = new dashboard();
        this.Hide();
        d.Show();
    }

Finally we can redirect to another page by click the login button.

  •  Tags:  
  • Related