VB.NET Windows Forms

VB.NET Windows

Windows Forms in VB.NET

The Windows Forms platform supports Windows GUI programs. And the VB.NET language can be used to control these programs. We run arbitrary code as a result of event handlers. This section covers Windows Forms in the VB.NET language.

These VB articles show how to use Windows Forms. Windows Forms provides a graphical user interface.

TextBox

In Windows Forms, you add controls by dragging them to your form in Visual Studio. Then, you can double-click on those controls and add event handlers such as Form1_Load to your program. In those event handlers, you can add your VB.NET statements to perform the actions you want.

Windows Forms program [VB.NET]

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, _
			   ByVal e As System.EventArgs) Handles MyBase.Load
	Text = "Dot Net Perls"
	TextBox1.Text = "VB.NET is awesome!"
    End Sub
End Class

Result: See screenshot for example.

MessageBox

If you are using Windows Forms, the easiest way to show a dialog box or alert box is to call MessageBox.Show. This results in a customizable dialog window.

MessageBox.Show Examples

BackgroundWorker

One of the easiest ways to use threads in your VB.NET program is with the BackgroundWorker type, which can be set up directly in the Visual Studio Windows Forms designer.

BackgroundWorker Use

DataGridView

DataGridView example

The DataGridView control is one of the most popular and important controls in Windows Forms. With DataGridView, you can display your tabular data in a variety of ways. The DataGridView is much faster to deploy and more efficient at runtime than most other solutions in Windows Forms for its intended use.

DataGridView Usage

Summary

The VB.NET programming language

Windows Forms is one of the fastest ways to develop a usable graphical user interface with the VB.NET language. By dragging controls in Visual Studio, we can develop interactive applications and hook up event handlers written in VB.NET code.

.NET