130 likes | 177 Views
Explore how to initialize variables, handle form events, use methods effectively, and harness control properties in VB.NET forms. Learn to control form behavior to enhance user experience and streamline application development.
E N D
Forms have - • Properties • Events • Methods • Remember, a method is something the object does to itself. An example is a form printing on itself or a list adding or removing items to and from itself.
EVENT Form_Load Form_Unload Form_Activate Form_Deactivate Form_Resize PURPOSE and USES Initialize variables and controls Keep things straight as form closes Whenever form is switched to Whenever form is switched from Whenever form is resized Form Events With Activate and Deactivate the form remains available to switch to and from
Form Methods • frmMyForm.Show • frmMyForm.Hide • Shorthand method for changing the visible property.
Form Properties • StartUpPosition 0 Unspecified • Center of Current (Owner) Form • Center of Screen • Upper Left
Form Properties • ScaleMode • Twips 4 Characters
Form Properties • AutoRedraw T/F True tells the computer to redraw the form again every time it is accessed. Keeps graphics current and printing that form current.
Icon MaxButton MinButton MousePointer WindowState NUMEROUS Appearance BackColor BorderStyle Caption ControlBox Enabled FontStyle Form Properties
Form Collections • A collection is a group of like things that can be referred to in a like manner, much like an array. • Some collections are automatically generated: forms, objects on a form, etc • Forms(1), Forms(2), etc • intNumForms=Forms.Count Gives the number of Forms
Control Collections • intNumberOfControls = _frmMyForm.Count
Printing on forms • Switch ScaleMode to 4 – Characters • frmMyForm.Print “This is a method” • .CurrentX and .CurrentY • Put a colon (;) to keep the next text on the same line • Spc(x), Tab(x) for Spaces and Tab
For Each • The For Each loop is like a for next loop, but is used with collections. For Each Whatever in frmMyForm Whatever.Enabled=false Next