Free since 2005 · No login required
AT

Academic Tutorials

Learn at your own pace

site-mobile-top-banner · 320x50

WinForms in VB.Net

Added 29 Jul 2008


As stated earlier, .Net provides the WinForm and other controls through base classes in the System.Windows.Forms namespace. The class System.Windows.Forms.Form is the base class of all WinForms in .Net. In order to design a windows application, we need to:
1.Create a Windows Application project in Visual Studio.Net, or add references to System.Windows.Forms and System.Drawing to your current project. If you are not using Visual Studio at all, use the /reference option of the command line compiler to add these assemblies.
2. Write a new class to represent the WinForm and derive it from the System.Windows.Forms.Form class:

Public Class MyForm
Inherits System.Windows.Forms.Form
...

3. Instantiate various controls, set their appropriate properties and add these to MyForm's Controls collection.

4. Write another class containing the Main() method. In the Main()
method, call the System.Application.Run() method, supplying it with an
instance of MyForm.



Class Test
Public Sub Main()
Application.Run(New MyForm())
End Sub
End Class