How To Create Multiple Forms In Visual Basic
- Home
- »
- VB.NET
- »
- WINDOWS FORMS IN VB.NET
Working with Multiple Forms in Visual Basic .NET
In this article, I will explain you about how to Add New Form to the Project and Working with Multiple Forms in Visual Basic .NET.
- 7821
Add New Form to the Project
Many times we want to add new forms to our project. We can add a new form to the project by selectingProject->Add New Item from the main menu which displays a window which has many items to add to your project.
SelectWindows Formfrom that window and click onAdd button to add a new form to the project.
We can also add a new form from theSolution Explorer. To add a new form from the Solution Explorer, right-click on the project name in Solution Explorer and SelectAdd-> Windows Formwhich again displays a window selectWindows Form and click onAdd button.
Now you have to make some changes if you want to display the form which you added when you run the application . For this right-click on the project name inSolution Explorer selectProperties which displays aWindow.
On this window click the drop-down box named as Startup Form. By this you can able to see each and every form of your project.
Now which form you want to displayed when you run the application select that form and run your application. When you run the application, the form you assigned asStartup Form will be displayed.
Working with Multiple Forms
In visual Basic .NET we can work with multiple forms. For example, take three forms in your applicationForm1,Form2andForm3.Now drag a buttons form the toolbox onForm1andForm2.Nowwe want to openForm2 when a button on theForm1 is clicked and when we clicked the button onForm2,Form3 will displayed. Double click onButton1 onForm1 and place the code given below in the click event of the button.
Public ClassForm1
Dim F2AsNewForm2
'creating a reference to Form2
PrivateSub Button1_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles Button1.Click
F2.Show()
End Sub
End Class
After that, Double click onButton1 onForm2 and place the code given below in the click event of the button.
Public ClassForm2
Dim F3AsNewForm3
'creating a reference to Form3
PrivateSub Button1_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles Button1.Click
F3.Show()
End Sub
End Class
Summary
I hope this article will help you to understand about Add New Form to the Project and Working with Multiple Forms in Visual Basic .NET
How To Create Multiple Forms In Visual Basic
Source: https://www.dotnetheaven.com/article/working-with-multiple-forms-in-visual-basic-.net
Posted by: carmichaelnower1967.blogspot.com
0 Response to "How To Create Multiple Forms In Visual Basic"
Post a Comment