System.Windows.Forms.Form



The “System.Windows.Forms.Form” class offers few properties, methods and events for each user-defined form class.
Properties of “System.Windows.Forms.Form” Class
Property
Description
Name
Specifies the name of the form class.
Text
Specifies the title bar text of the form.
Icon
Specifies the icon of the form, displayed at left most side of the form title bar. It requires icon file with “.ico” file.
ShowIcon
Specifies whether the form icon is to be displayed or not.
ControlBox
Specifies whether the control box is to be displayed or not. Here the control box means minimize, maximize and close buttons.
MinimizeBox
Specifies whether the minimize button is to be displayed or not.
MaximizeBox
Specifies whether the maximize button is to be displayed or not.
ShowInTaskBar
Specifies whether the task bar icon is to be displayed or not.
WindowState
Specifies the status of the form window. (Normal / Minimized / Maximized)
BackColor
Specifies the background color of the form.
BackgroundImage
Specifies the background image of the form. It requires an image file of any image format.
BackgroundImageLayout
Specifies mode of the background image. (None / Tile / Center / Stretch / Zoom)
Size (Width and Heght)
Specifies the size of the form (pixels format).
Location (X and Y)
Specifies the position of the form (pixels format).
Cursor
Specifies the mouse cursor style. (Arrow, Hand etc.)
Enabled
Activates / Deactivates the functionality of the entire form.
AutoScroll
Enables / Disables automatic activation of scrollbars in the form.
Font
Specifies default font for all the controls of this form.
ForeColor
Specifies default foreground color for all the controls of this form.

Syntax to access the Properties in the code: this.Property = value;

Methods of “System.Windows.Forms.Form” Class
Method
Description
Hide()
Makes the form invisible at run time.
Show()
Makes the form visible at run time.
Close()
Closes the form.

Syntax to access the Properties in the code: this.Method();

Events of “System.Windows.Forms.Form” Class
Event
Description
Load
Executes whenever the form is loaded in the memory at run time, before the form is displayed on the screen.
Shown
Executes after the form is displayed on the screen.
FormClosed
Executes when the form is closed.
Click
Executes when the user clicks on the form at run time.
DoubleClick
Executes when the user double-clicks on the form at run time.
MouseMove
Executes when the mouse pointer is moves across the form.
MouseEnter
Executes when the mouse pointer is focused on to the form.
MouseLeave
Executes when the mouse pointer is out of the form.
Move
Executes when the form is moved at run time, using keyboard or mouse.
Resize
Executes when the form is resized at run time.
KeyPress
Executes when any key is pressed on the keyboard, while running on the form.
Enter
Executes when the focus is got on to the form.
Leave
Executes when the focus is out of the form.

Assign Property Values at Run Time
Property
Statement to assign the value at run time
Name
Not possible to change at run time.
Text
this.Text = “xxxxx”;
Icon
this.Icon = new System.Drawing.Icon(“icon file path”);
ShowIcon
this.ShowIcon = true / false;
ControlBox
this.ControlBox = true / false;
MinimizeBox
this.MinimizeBox = true / false;
MaximizeBox
this.MaximizeBox = true / false;
ShowInTaskBar
this.ShowInTaskBar = true;
WindowState
this.WindowState = System.Windows.Forms.FormWindowState.Normal;
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
BackColor
this.BackColor = System.Drawing.Color.xxxxxxx;
BackgroundImage
this.BackgroundImage = System.Drawing.Image.FromFile(“image file path”);
BackgroundImageLayout
this.BackgroundImageLayout=System.Windows.Forms.ImageLayout.xxxxx
Size
this.Size = new System.Drawing.Size(width, height);
Location
this.Location = new System.Drawing.Point(x, y);
Cursor
this.Cursor = System.Windows.Forms.Cursors.xxxxx;
Enabled
this.Enabled = true / false;
AutoScroll
this.AutoScroll = true / false;
Font
this.Font = new System.Drawing.Font(“font name”, size);
ForeColor
this.ForeColor = System.Drawing.Color.xxxxxxx;


No comments:

Post a Comment