Professional Documents
Culture Documents
UNIT II - Lecture 1
Introduction to the windows forms
What is a Window Form?
• Visual Basic Form is the container for all the controls that make up the user interface
• Every window 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 to create a Windows Forms Application.
Creating a Window Forms Application by the following steps in Microsoft Visual Studio
- File → New Project → Windows Forms Applications
Finally, select OK, Microsoft Visual Studio creates a project and displays following window
Form with a name Form1.
Every form will have title bar on which the form's caption is displayed and there will be
buttons to close, maximize and minimize the form shown below −
click the icon on the top left corner, it opens the control menu, which contains the various
commands to control the form like to move control from one place to another place, to
maximize or minimize the form or to close the form.
Setting the Title Bar Text:
Every form will have title bar on which the form's caption is displayed and there will be
buttons to close, maximize and minimize.
Title Bar Height:
Height of the title bar can be changed by using the Style.TitleBar.Height property.
Me.Style.TitleBar.Height = 45
Text Alignment:
Text on the title bar can be aligned horizontally and vertically by using
the Style.TitleBar.TextHorizontalAlignment and Style.TitleBar.TextVerticalAlignment
properties respectively.
Me.Style.TitleBar.TextHorizontalAlignment = HorizontalAlignment.Center
Me.Style.TitleBar.TextVerticalAlignment = VerticalAlignment.Top
• Normal state
• Hover state
• Pressed state
Icons for the title bar buttons can be changed to normal, hovered, and pressed states by using
the image properties of the corresponding state such
as CloseButtonHoverImage and MaximizeButtonPressedImage.
Me.MaximizeBox = False
Me.Style.TitleBar.AllowRichText = True
Adding rich text to the Text property will have no effect, if the AllowRichText property
is false.
The SfForm allows you to load any user control into the title bar instead of title bar text by
using the TitleBarTextControl property. Size of the user control should be set properly to fit
the control within the title bar.
Icon backcolor:
Can customize the back color of the icon in title bar using the IconBackColor property.
Me.Style.TitleBar.IconBackColor = Color.Olive
Caption image:
Can change the caption image in title bar by using the CaptionImage property.
Me.Style.TitleBar.CaptionImage = SystemIcons.Error.ToBitmap()