![]() |
The Forms of an Application |
|
Introduction |
|
The form is the most fundamental object used in an application. By itself, a form does nothing. Its main role is to host other objects that the user uses to interact with the computer: ![]() |
There are various ways you can get a form to your application:
In Lesson 2, we saw that a was based on the Form class that is defined in the System.Windows.Forms namespace created in the System.Windows.Forms.dll assembly. Therefore, if you start an application from scratch and you want to use a form in it, you can include the System.Windows.Forms.dll library to your application. To refer to a form, you can include the System.Windows.Forms namespace in your application. As seen in Lesson 2, to create a form-based application, you can derive a class from Form. Here is an example: Imports System.Windows.Forms
Module Exercise
Public Class Starter
Inherits Form
Dim components As System.ComponentModel.Container
Public Sub New()
InitializeComponent()
End Sub
Public Sub InitializeComponent()
End Sub
End Class
Function Main() As Integer
Dim frmStart As Starter = New Starter
Application.Run(frmStart)
Return 0
End Function
End Module
Like any other control, a form must have a name. If you derive a class from Form, the name you use for the class would be the name of the form. If you add a form from the Add New Item dialog box, you must also give it a name. If you create a Windows Application from the New Project dialog box, the wizard would create a default form for you named Form1. However you create or get a form, you can change its name. To change the name of a form, in the Solution Explorer, right-click the name of the form and type a new name with the .cs extension.
|
|
|
||
| Home | Copyright © 2008 FunctionX, Inc. | Next |
|
|
||