GST Billing Software

Windows Forms Basics What is the use of Form in Visual Basic? Create a Windows Forms Application project

header image

Windows Forms Basics

Erachana Line

A Windows forms application is one that runs on the desktop computer. A Windows forms application will normally have a collection of controls such as labels, textboxes, list boxes, etc.

Windows Forms is a graphical user interface application programming interface (API) included as a part of Microsoft's .NET Framework. Winforms is a library for creating GUI applications.

Visual Basic Form is the container for all the controls that make up the user interface. Every window you see in a running visual basic application is a form, thus the terms form and window describe the same entity. Visual Studio creates a default form for you when you create a Windows Forms Application.

1. On the menu bar, choose File, New, Project. The dialog box should look like this.

2. Choose Visual C# in the Installed Templates list.

3. In the templates list, choose theWindows Forms Application icon. Name the new form WindowsFormsApplication1, and then choose the OK button.

Visual Studio creates a solution for your program. A solution acts as a container for all of the projects and files needed by your program.

4. Visual Studio opens an interface. The interface contains three windows: a main window, Solution Explorer, and the Properties window. which is shown below.

You can also display windows by using menu commands. On the menu bar, choose View, Properties Window or Solution Explorer.

  • Main window: In this window, you'll do most of your work, such as working with forms and editing code. In the illustration, the window shows a form in the Form Editor. At the top of the window, Form1.cs [Design] tab appear.
  • Solution Explorer window: In this window, you can view and navigate to all items in your solution. If you choose a file, the contents of the Properties window changes. If you open a code file, the code file or a designer for the code file appears. A designer is a visual surface onto which you can add controls such as buttons and lists. For Visual Studio forms, the designer is called the Windows Forms Designer.
  • Properties window: In this window, you can change the properties of items that you choose in the other windows. For example, if you choose Form1, you can change its title by setting the Text property, and you can change the background color by setting the Backcolor property.

5. On the menu bar, choose File, Save All .

To run your program

1. Use one of the following methods to run your program.

1. Choose the F5 key.

2. On the menu bar, choose Debug, Start Debugging.

3. On the toolbar, choose the Start Debugging button, which appears as follows.

Start Debugging toolbar button
Start Debugging toolbar button

2. Visual Studio runs your program, and a window called Form1 appears. The following diagram shows the program you just built. The program is running, and you will soon add to it.

Windows Form Application program running

3. Go back to the Visual Studio integrated development environment (IDE), and look at the new toolbar. Additional buttons appear on the toolbar when you run a program. These buttons let you do things like stop and start your program, and help you track down any errors (bugs) it may have. For this example, we're just using it to start and stop the program.

Debugging toolbar
Debugging toolbar

4. Use one of the following methods to stop your program.

1. On the toolbar, choose the Stop Debugging button.

2. On the menu bar, choose Debug, Stop Debugging.

3. Choose the X button in the upper corner of the Form1 window.