You are on page 1of 18

12/11/2013

Working with Windows Forms and Controls 1st Part


Prepared by : PROF . JEFFERSON A. COSTALES, MIT , IBM-CDA, MCTS, ZCE Professional Lecturer, MIS Consultant IBM Certified Database Associate Certified for IBM DB2 Software Microsoft Certified T echnology Specialist TS: Microsoft.NET Framework 3.5, Windows Forms Application Development

Working with Windows Forms and Controls


Windows Forms Windows Controls
T ext Box
Button Label Check Box Radio Button List Box Combo Box Picture Box T ool tip T imer Built-in Dialog
Working with Windows Forms and Controls Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
2/105

ITELE1: Visual Basic. NET

Windows Forms Overview


Parts of a Window s Form
Title Bar(Caption Bar)- displays the forms title. It also includes the control box which holds the Minimize, Maximize, and Close buttons. Menu bar- where forms can also have toolbars, with buttons that correspond to menu items Controls placed in the forms client area Client Area (workspace) the area under the title bar and under any menu bars toolbars excluding the forms border.
Working with Windows Forms and Controls
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
3/105

Windows Forms Overview


Parts of a Window s Form
Title Bar
Menu Bar

Client area

Controls

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

4/105

Creating a Windows Application


File > New Project

Adding Controls
Two methods in adding controls
Double-click the control to be added in the toolbox and then drag the new control to the desired place in the form; or simply click and drag the control from the toolbox

Select Windows under Visual Basic in the Project Types box. Click the Windows Application icon in the Templates box.

Type in application name then click OK.


Working with Windows Forms and Controls Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
5/105

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

6/105

12/11/2013

Form Property Page


AcceptButton

Form Properties
Property Description
Returns or sets the button automatically clicked when the user presses the ENTER. Returns the currently active form in the application. Returns the currently active multiple-document interface (MDI) child window. Returns or sets whether the form will accept data that the user drags onto it. Returns or sets whether the form adjusts to fit the font used and scales its controls. Returns or sets a value indicating whether the form enables autoscrolling. Returns or sets mode by which form automatically resizes itself.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
8/105

ActiveForm ActiveMdiChild AllowDrop AutoScale AutoScroll AutoSizeMode


Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

Working with Windows Forms and Controls

7/105

Working with Windows Forms and Controls

Form Properties
Property
BackColor

Form Properties
Property Description
Returns or sets the foreground color of the form. Returns or sets the border style of the form. Returns or sets the forms height(in pixels) Returns or sets the icon for the form. Returns a value indicating whether the form is a multiple-doc um ent interface (MDI) child form. Returns or sets a value indicating whether the form is a container for multiple-docu me nt interface (MDI) child forms. Returns or sets the coordinates of the upperleft corner of the form with respect to the upper-left corner of the screen.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
10/105

Description
Sets the background color. ForeColor

BackgroundIma ge
CancelButton ClientSize ControlBox

Returns or sets the background form.

image of a
FormBorderStyle Height Icon IsMdiChild IsMdiContainer

Returns or sets the button control that is clicked when the user presses ESC key. Returns and sets the size of the client area of the form. Returns or sets a value indicating whether a control box is displayed in the caption bar of the form. Returns or sets the mouse cursor when the mouse is over the form. Returns or sets the dialog result for the form. Returns or sets the text font in the form.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
9/105

Cursor Dialog result Font


Working with Windows Forms and Controls

Location

Working with Windows Forms and Controls

Form Properties
Property
MaximizeBox

Form Properties
Property
MinimumSize Modal

Description
Returns or sets a value indicating whether the Maximize button is displayed in the caption bar of the form. Returns the maximum size the form can be resized to. Returns an array of forms that represent the multiple-docu me nt interface (MDI) child forms that are parented to this form. Returns or sets current multiple-doc um ent interface (MDI) parent form of this form. Returns or sets the menu that is displayed in the form Returns or sets a value indicating whether the Minimize button is displayed in the caption bar of the form.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
11/105

Description
Returns or sets the minimum size the form can be resized to. Returns a value indicating whether this form is displayed modally.

MaximumSize MdiChildren

Name
Opacity OwnedForms

Returns or sets the name of the form.


Returns or sets the opacity level of the form. Returns an array of Form objects that represent all forms that are owned by this form. Returns or sets the form that owns this form. Returns or sets a value indicating whether the form is displayed in the Windows taskbar. Returns or sets the size of the form.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

MdiParent Menu MinimizeBox

Owner ShowInTaskbar Size


Working with Windows Forms and Controls

Working with Windows Forms and Controls

12/105

12/11/2013

Form Properties
Property
StartPosition Text TopMost TransparencyKey Visible Width WindowState

Form Methods
Methods Acticate Description Activates the form and gives it focus.

Description
Returns or sets the starting position of the form at run time. Returns or sets the text in the title bar. Returns or sets a value indicating whether the form should be displayed a topmost form. Returns or sets the color that will represent transparent areas of the form. Returns or sets whether the form is visible. Returns or sets the width of the form (in pixel) Returns or sets the forms window state.

AddOwnedForm
BringToFront Close Focus Hide LayoutMdi

Adds an owned from to his form.


Brings a form to the front of others. Close the form. Sent input focus to the form. Hides the form Arranges the multiple-document interface MDI) child forms within the MDI parent form. Removes an owned form. Send the for to the back.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
14/105

RemovedOwnedForm SendToBack

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

13/105

Working with Windows Forms and Controls

Form Methods List


SetDesktopBounds SetDesktopLocation

Form Methods
Methods Description Sets the bounds of the form in desktop coordinates. Sets the location of the form in desktop coordinates.

Show
ShowDialog UpdateDefaultButton

Displays the form.


Shows the form as a modal dialog box. Updates which button is the default button.

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

15/105

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

16/105

Form Events List


Events

Form Events
Description

Activated
Click Closed Closing Deactivated DoubleClick Enter

Occurs when the form is activated in code or by the user.


Occurs when the form is clicked. Occurs when the form is closed. Occurs when the form is closing. Occurs when the loses the focus. Occurs when the form is double clicked. Occurs when the form is entered by the mouse.

KeyPress
Load MouseMove Move Paint Resize
Working with Windows Forms and Controls Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
17/105

Occurs when the key is pressed while the form has focus.
Occurs before a form is displayed for the first time. Occurs when the mouse pointer is moved over the form. Occurs when the is moved. Occurs when the form is redrawn. Occurs when the form is resized.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
18/105

Working with Windows Forms and Controls

12/11/2013

Handling Windows Forms in a Code


Setting a Forms Staring Position
FormStartPosition.CenterParent FormtStartPosition.CenterScreen FormStartPosition.Manual FromStartPosition.WindowDefaultBounds FormStartPosition.WindowsDefaultLocation

Handling Windows Forms in a Code


Setting and Getting Forms and Controls sizes and Locations
To create a new Size object: Size (x_size, y_size) To create a new Point object: Point (x_location, y_loacation)

Example :
Form1.Size = New Size(100, 100) Form1.Location = New Point(0,0)

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

19/105

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

20/105

Handling Windows Forms in a Code


Displaying and Hiding Forms and Controls
to display forms and controls:
set the Visible Property to True or False

Handling Windows Forms in a Code


Customizing a Forms Border and Title bar
FormBorderStyle.Fixed3D FormBorderStyle.FixedDialog FormBorderStyle.FixedSingle FormBorderStyle.FixedToolWindow FormBorderStyle.None FormBorderStyle.Sizable FormBorderStyle.SizableToolWindow

Example:
Form1.Visible = False Button1.Visible = True

To show and hide forms and controls, use the Show and Hide methods. Example:
From1Hide() Form1.Show()
Working with Windows Forms and Controls
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
21/105

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

22/105

Handling Windows Forms in a Code


Setting a Forms State
FormWindow State.Maximized Fow mWindow State.Minimized Formw indow State.Normal

Using Built-in Message and Input Dialogs


Working with the MsgBox Function
MessageBox Displays application-related information to the user

Syntax:
Function Msg (Pro mpt As Objec t [, Buttons _As MsgBoxStyle = Msg BoxStyle.OKO nly] [, Titl e_As Objects = Nothing ]) As MsgBox ResultArgume nts

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

23/105

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

24/105

12/11/2013

Using Built-in Message and Input Dialogs


Working with the MsgBox Function
MsgBoxStyle.
OKOnly OkCancel AbortRetryIgnore YesNoCancel

Using Built-in Message and Input Dialogs


Working with the MsgBox Function
MsgBoxStyle.
DefaultButton1 DefaultButton2 First button is default. Second button is default.

Description
Ok Bbutton only (default) Ok and Cancel buttons. Abort, Retry , and Ignore buttons. Yes, No, and Cancel buttons.

Description

DefaultButton3
ApplicationModal

Third button is default.


Application modal, which means the user must respond to the message box before continuing work in the current application. System modal, which means all applications are unavailable until the user dismisses the message box. Foreground message box window. Right-aligned text.

YesNo
RetryCancel Crtical Question Exclamation Information

Yes and No buttons.


Retry and Cancel buttons. Critical Message. Warning query . Warning message. Information message.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
25/105

SystemModal MsgBoxSetForeground MsgBoxRight

MsgBoxRtlReading
MsgBoxHelp

Regit-to-left reading text (Hebrew and Arabic systems).


Help text.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
26/105

Working with Windows Forms and Controls

Working with Windows Forms and Controls

Using Built-in Message and Input Dialogs


Working with the MsgBox Function
MsgBoxStyle. Ok Description Ok button was pressed.

Using Built-in Message and Input Dialogs


Working with the MsgBox Function Example
Pri vat e S ub Bu tto n1 _Cl ick (B yVa l sen der As_ Sys tem .O bje ct, B yVa l e A s S ys tem .Ev en tAr gs) Han dle s_B ut ton 1.C li ck Dim in tRe tu rnV alu e As Int eg er int Ret urn Va lue=Ms gB ox( "Th is is a me ssa ge bo x! ", Msg Box St yle .OK Ca nce l + M sgB ox Sty le. In for mat io n +_M sgB oxS ty le. Sys te mMo dal, "Ms sa ge Box ") If (in tRe tu rnV alu e = M sgB ox Res ul t.O K) Th en Tex tBo x1. Te xt = " Yo u c lic ke d t he OK but ton . " Els e Tex tbo x1. Te xt = " Yo u c lic ke d t he Can cel bu tt on. " End If End Su b
27/105

Cancel
Abort Retry Ignore Yes No

Cancel button was pressed


Abort button was pressed. Retry button was pressed. Ignore button was pressed Yes button was pressed. No button was pressed.

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

28/105

Using Built-in Message and Input Dialogs


Working with the MsgBox.Show Method Syntax:

Using Built-in Message and Input Dialogs


Working with the MsgBox.Show Method
MessageBoxButtons
AbortRetryIgnore OK

Descriptions
T he message box contains Abort, Retry , and Ignore buttons. T he message box contains an OK button.

Fun cti on Sh ow (By Va l t ext A s S tr ing ,_B yV al cap ti on As Str ing , ByV al bu tto ns As Ms gB oxB utt on s, Msg Bo x ico n A s M es sag eBo xI con , B yV al de fau ltB ut ton As Mes sag eBo xD efa ult Bu tto n, By Val o pti ons A s Mes sge Box Op tio ns) A s D ial og Re su lt

OKCancel
RetryCancel YesNo YesNoCancel

The message box contains Ok and Cancel buttons.


T he message box contains Retry and Cancel buttons. T he message box contains Yes and No buttons. T he message box contains Yes, No, and Cancel buttons.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
30/105

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

29/105

Working with Windows Forms and Controls

12/11/2013

Using Built-in Message and Input Dialogs


Working with the MsgBox.Show Method
MessageBoxButtons Asterisk Error Descriptions T he message box contains a symbol consisting of a lowercase letter i in a circle. T he message box contains a symbol consisting of white X in a circle with a red background.

Using Built-in Message and Input Dialogs


Working with the MsgBox.Show Method
MessageBoxButtons Information None Question Stop Descriptions T he message box contains a symbol consisting of lowercase letter. T he message box contains no symbols. T he message box contains a symbol consisting a question mark in a circle. T he message box contains a symbol consisting of white X in a circle with a red background. T he message contains a symbol consisting of an exclamation point in a triangle with yellow background.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

Excalamation

The message box contains a symbol consisting of an exclamation point in a triangle with a yellow background.
T he message box contains a symbol consisting of a white X in a circle with a red background.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

Hand

Warning

Working with Windows Forms and Controls

31/105

Working with Windows Forms and Controls

32/105

Using Built-in Message and Input Dialogs


Working with the MsgBox.Show Method
MessageBoxButtons Button1 Button2 Button 3 Descriptions T he first button on the message box is the default button. T he second button on the message box is the default button. T he third button on the message box is the default button.

Using Built-in Message and Input Dialogs


Working with the MsgBox.Show Method
MessageBoxButtons DefaultDesktopOnly Descriptions T he message box is displayed on the active desktop. T his constant is the same as ServiceNotification except that the system displays the message box only on the default desktop of the interactive window station. T he message box text is right-aligned. Specifies that the message box is displayed with right to left reading order. T he message box displayed on the active desktop. The caller is a service notifying the user of an event. T he function displays a message box on the current active desktop, even if there is no user logged on to the computer.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
34/105

RightAlign RltReading Serv iceNotification

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

33/105

Working with Windows Forms and Controls

Using Built-in Message and Input Dialogs


Working with the MsgBox.Show Method Example:
Private Sub Button2 _Click(B yVal sen der As_ System.O bject, ByVal e As System.E ventArgs ) Handle s_Butto n2_Click Dim intRetu rnValue As Integ er intReturnVa lue = Ms gBox.Sho w("This is also a messa ge box! ", "Me ssage Bo x", Mess ageBoxBu ttons.O KCancel, MessageBoxI con.Info rmation, MessageBoxD eafaultB utton.Bu tton1, MessageBoxO ptions.D efaultDe sktopOnl y) If (intRetu rnValue = Dialog REsult.O K) Then TextBox1.Te xt = "Yo u clicke d the OK button ." Else TextBox1.Te xt = "Yo u cliked the Can cel button." End If End Sub
Working with Windows Forms and Controls Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

Using Built-in Message and Input Dialogs


Wotking with the InputBox Function Syntax:
Public Func tion Inp utBox (P rompt As String [, Titl e_As String = "" ][,Defau ltRespon se As St ring = ""][,_XP os As Integer = - 1][,YPos As Inte ger = -1 ]) As_S tring

Example:
Pri vat e S ub Bu tto n3 _Cl ick (B yVa l sen der A s Sys tem .Ob je ct, By Va l e As S yst em .Ev ent Ar gs) Han dle s B ut ton 3.C li ck Tex tBo x1. Te xt = " Yo ur nam e is " & Inp utB ox( "P lea s t yp e y our n ame ." ) End Su b
Working with Windows Forms and Controls Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

35/105

36/105

12/11/2013

Creating Applications with Multiple Forms


To add another form
Project > Add Windows From

MDI Applications
Multiple Document Interface (MDI) Windows can display multiple child windows inside them MDI Application Foundation of MDI Application Contains the MDI child windows To create the MDI parent form Set the IsMDIContainer property of the first form to True To manage the MDI children Use the Show and Hide Methods
Working with Windows Forms and Controls Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

Select the windows Form icon from the Templates box then click Add

To change Startup object


Project > Properties On the application tab, select a form from the startup form dropdown box

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

37/105

38/105

Text Box
Window s Forms Text Box control
Used to get input form the user to to display text

TextBox Property Page

Example of TextBox

Types of TextBox
Standard Textbox Rich text
Working with Windows Forms and Controls
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

39/105

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

40/105

TextBox Properties
Property

TextBox Properties
Description Returns the maximum number of characters allowed in the text box. The default value is 0, meaning that there is no limit on the length. Gets or sets a value indicating whether this is a multiline TextBox control. Gets or sets the character used to mask characters of a password in a single-line TextBox control. MaxLength

Property AcceptsReturn

Description Returns or sets a value indicating whether pressing Enter in a multiline TextBox control creates a new line of text in the control or activates the default button for the form.

Multiline PasswordChar

BackColor
BorderStyle CharacterCasing

Returns or sets the border style of the text box.


Returns or sets the border style of the text box. Gets or sets whether the Textbox control modifies the case of characters as they are typed.
ReadOnly ScrollBars
Size

Gets or sets a value indicating whether the contents of the TextBox control can be changed. Gets or sets which scroll bar should appear in multiline TextBox control.
Gets or sets the expected length of the specified text box, in characters. The default value for the size of a text box is 0, which means that the browser will use its default text box length.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

Font
ForeColor

Returns or sets the font text of the TextBox.


Returns or sets the foreground (text) colot.

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

41/105

Working with Windows Forms and Controls

42/105

12/11/2013

TextBox Properties
Property Text TextAlign Description Returns or sets the text content of the TextBox control. Returns or sets how text is aligned in a TextBox control.

TextBox Method Lists

WordWrap

Returns or sets a value indicating whether the text content wraps within a multiline text box.

Example:
strText = TextBox1.Text TextBox1.Text = strText

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

43/105

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

44/105

TextBox Methods
Methods AppendT ext Description Appends text to the text currently in the text box.

Creating Read-Only TextBox


Set the TextBox controls ReadOnly property to True to lock the text box so that the user cant enter or modify any text. Disable a TextBox by setting the Enable property to False to gray out the textbox and not allow the user to enter or modify any text. Use a label.

Clear
Copy Cut Paste

Clears the text from the text box.


Copies the selected text in the text box and places it in clipboard. Deletes the current selection in the text box and places it in a clipboard. Replaces the current selection in the text box with the contents of the Clipboard.

Select
SelectAll Undo

Selects text in the text box.


Selects all the text in the text box. Undoes the last operation in the text box.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

Working with Windows Forms and Controls

45/105

Working with Windows Forms and Controls

46/105

Creating Multiline TextBox


Set the Multiline property to TRUE Set the ScrollBars property to an appropriate value.
Value None Description Use this value if the text will be a paragraph that almost always fits the control. T he user can use the mouse pointer to move around inside the control if the text is too long to display all at once. T his value if you want to display a list of lines, some of which may be longer than the width of the TextBox control. Use the value if the list may be longer than the height of the control. Use this value if the list may be longer than the height and width of the control.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
47/105

Creating Multiline TextBox


Set the WordWrap property to an appropriate value
Value False Description Text in the control will not automatically be wrapped, so it will scroll to the right until a line break is reached. Use this value if you chose Horizontal scroll bars or Both from the ScrollBars property .
T he horizontal scrollbar will not appear. Use this value if you chose Vertical scroll bars or None form the ScrollBars property to display one or more paragraphs.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

Horizontal Vertical Both

True

Working with Windows Forms and Controls

Working with Windows Forms and Controls

48/105

12/11/2013

Buttons
Windows Forms Text Box control
Allows the user to click it to perform an action Can display both text and images When clicked, it looks like it was pushed and released

Buttons Properties
Property DialogResult Description Returns or sets a value returned to the parent form when the button is clicked. Returns or sets whether the button has a flat appearance. Returns or sets an image displayed Returns or sets the alignment of the image in a button. Returns or sets alignment of the text in the button.

Example of Button

FlatStyle Image ImageAlign T extAlign

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

49/105

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

50/105

Buttons Methods
Method Description

Buttons Events
Ev ents Description

Click
DragDrop

Fires when the button is clicked.


Occurs when drag and drop operation is completed.

DragEnter
DoubleClick GotFocus Keypress KeyUp KeyDown

Triggers when an object is dragged inside the controls bound


Occurs when the user double-clicks the button. Occurs when control receives a focus. Fires when key is released is pressed while the control has focus. Fires when a key is released while the control has focus. Fires when a key is pressed while the control has focus.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
51/105

Click
Command

Occurs when the Button control is clicked.


Occurs when the Button control is clicked.

Working with Windows Forms and Controls

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

52/105

Clicking a Button in a Code


Click event
Raised when the Button control is clicked. When Forms Label Control

Label
Displays read-only text on a form Displays text on the client area of a form

Example:
Pub lic Cl as s F orm 1 Dim iT ime s As int eg er = 0 Pri vat e S ub Bu tto n1 _Cl ick (B yVa l sen der A s Sye tem .Ob je ct, By Va l e As S yst em .Ev ent Ar gs) Ha nd els But ton 1.C li ck

Example of a Label

iti mes = it Tim es + 1 But ton 1.T ex t = "I w as Cli ck ed " & i tim es & "ti me s"
End Su b End Cl ass
Working with Windows Forms and Controls Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE Working with Windows Forms and Controls Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

53/105

54/105

12/11/2013

Label Properties
Properties
AutoSize

Label Properties
Properties
ImeMode

Description
Returns or sets a value indicating whether the control is automatically resized to display its entire contents.

Description
Returns or sets the Input Method Editor (IME) mode supported by this control.

BerderStyle
FlatStyle Image

Returns or sets the labels border style.


Returns or sets the flat style appearance of the label control. Returns or sets the image that is displayed on Label.

T abStop
T ext T extAlign UseMnemonic

Returns or sets a value indicating whether the user can tab to the Label.
Returns or sets the text content of the label control. Returns or sets the alignment of text in the label. Returns or sets a value indicating whether the control interprets an ampersand character (&) in the controls Text property to be an access key prefix character.

ImageAlign
ImageIndex ImageList

Returns or sets the alignment of an image that is displayed in the control.


Returns or sets the index value of the image displayed on the label. Returns or sets the ImageList that contains the image to display in the Label control.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
55/105

Working with Windows Forms and Controls

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

56/105

Label Method
Methods Description

Aligning Text
ContentAlignment. BottomCenter BottomLeft BottomRight MiddleCenter MiddleLeft Description Vertically aligned at the bottom, horizontally aligned to the center. Vertically aligned at the bottom, horizontally aligned to the left. Vertically aligned at the bottom, horizontally aligned to the right. Vertically aligned at the middle, horizontally aligned to the center. Vertically aligned at the middle, horizontally aligned to the left.

Dispose
DrawImage Equals

Release all resources used by the Component.


Draws an Image within the specified bounds. Draws an Image within the specified bounds.

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

57/105

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

58/105

Aligning Text
ContentAlignment. Description

Check Box
Windows Forms Check Box
Indicates a Boolean such as Yes/No or True/False Consists of a small square with a text string next to it.

MiddleRight
T opCenter T opLeft T opRight

Vertically aligned at the middle, horizontally aligned to the right.


Vertically aligned at the top, horizontally aligned to the center. Vertically aligned at the top, horizontally aligned to the left. Vertically aligned at the top, horizontally aligned to the right.

Example of a CheckBox.

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

59/105

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

60/105

10

12/11/2013

CheckBox Properties
Properties
Appearance AutoCheck

CheckBox Properties
Properties
T extAlign

Description
Returns or sets the appearance of a CheckBox control. Returns or set a value indicating whether the Checked or CheckState values and the CheckBoxs apperance are automatically changed when the CheckBox is clicked. Returns or sets the horizontal and vertical alignment of the check mark on a CheckBox control. Returns or sets value indicating whether the CheckBox control is checked. Returns or sets the state of the CheckBox.

Description
Returns or sets the alignment of the text label associated with the CheckBox control. Returns or sets a value indicating whether the CheckBox will allow three check states rather than two.

ThreeState

CheckAlign Checked CheckState

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

61/105

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

62/105

CheckBox Methods
Methods AddAttributesToRen der LoadPostData Description Adds the HT ML attributes and styles of a CheckBox control to be rendered to the specified ouput stream. Processes the postback data for the CheckBox control. On-Click

CheckBox Methods
Methods Description Raises the Click event. Registers client script for generating postback prior to rendering on the client if AutoPostBack is True. Process a mnemonic character. Displays the CheckBox on the client. Saves the changes to the CheckBox view state since the time the page was posted back to the server.

OnPreRender ProcessMnemonic Render SaceViewState

LoadViewState
OnApperanceChanged OnCheckedChanged

Loads the previously saved view state of the CheckBox control.


Raises the AppearacneChanged event. Raises the CheckedChanged event of the CheckBox control. T his allows you to handle the event directly .

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

63/105

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

64/105

CheckBox in a Code
Example:
Pub lic Cl as s F orm 1 Pri vat e S ub Ch eck Bo x1_ Cli ck (By Va l s end er As Ob je ct, ByV al e A s Sys tem .E ven tAr gs ) H an dle s C he ckB ox1 .c lic k If Che ckB ox 1.C hec ke d = Tr ue Th en Che ckB ox1 .T ext = "C hec ked "

Radio Button
Windows Forms Radio Buttons
Also called as Option Buttons Are typically grouped with other RadioButtons Only one of the controls in the group can be checked at one time.

Example of a RadioButton.

Els e
Che ckB ox1 .T ext = "U nch eck ed " End If End Su b End Cl ass

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

65/105

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

66/105

11

12/11/2013

RadioButton Properties
Properties Description

RadioButton Methods
Methods LoadPostData Description Prcoeeses postback data for the RadioButton control.

Appearance
AutoCheck

Returns or sets a value determining the appearance of the Radio Button.


Returns or sets a value indicating whether the Checked value and the appearance of the control automatically change when the control is clicked. Returns or sets the location of the check box portion of the RadioButton. Returns or sets a value indicating whether the control is checked

OnCheckedChange
OnClick OnEnter

Raises the CheckedChanged event.


Raises the Click event. Raises the Enter event.

CheckAlign Cheked

OnHandleCreated OnMouseUp
OnPreRender PerformClick

Overrides the HandleCreated method. Raises the MouseUp event.


Raises the PreRender event. Generates a Click event for the control, simulating a click by a user.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

67/105

Working with Windows Forms and Controls

68/105

RadioButton in a Code
Example:
Pub lic Cl as s F orm 1

List Box
Windows Forms List Box Control
Controls that display a list of items, allowing the user to select one or multiple items.

Pri vat e S ub Ra dio Bu tto n1_ Ch eck ed Cha nge d( ByV al se nde r As Sys tem .Ob je ct, By Va l e As S yst em .Ev ent Ar gs) Ha nd les Rad ioB utt on 1.C lic k If Rad ioB ut ton 1.T ex t = Tr ue Th en
Rad ioB utt on 1.C hec ke d = Fa ls e Els e Rad ioB utt on 1.C hec ke d = Tr ue End If End Su b End Cl ass

Example of a ListBox.

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

69/105

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

70/105

List Box Properties


Properties Description

List Box Properties


Properties MultiColumn
ScrollAlwaysVisible SelectedIndeces SelectedItems SelectionMode Sorted T opIndex
71/105

Description Returns or sets whether the list box supports multiple columns.
Returns or sets whether the vertical scrollbar is always visible. Returns collection containing the (zero-based) indices of all currently selected items. Returns collection containing the currently selected items in the list box. Returns or sets the method in which items are selected in the list box. Returns or sets whether the items in the list box are sorted alphabetically . Returns or sets the index of the first visible item in the list box.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
72/105

ColumnWidth
DrawMode HorizontalExtent HorizontalScollBar IntegralHeight ItemHeight Items

Returns or sets the width of the columns (only for multicolumn list boxes).
Returns or sets the drawing mode for the control. Returns or sets the width by which the horizontal scroll bar of ListBox can scroll. Returns or sets a value indicating whether a horizontal scroll bar is displayed in the control. Returns or sets whether the list box should resize to avoid showing partial items. Returns or sets the height of list box items. Gets or sets a collection od the list box items.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

Working with Windows Forms and Controls

Working with Windows Forms and Controls

12

12/11/2013

List Box Method


Methods BeginUpdate Description Maintains performance while items are added to the ListBox one at a time by preventing the control from drawing until the EndUpdate method is called. Unselects all items in the ListBox. GetSelected EndUpdate FindString FindStringExact Resumes painting the Listbox control after painting is suspended by the BeginUpdatemethod. Find the first item in the ListBox that starts with the specified string Find the first item in the ListBox that exactly matches the specified string. IdexFromPoint SetSelected Methods GetItemHeight GetItemRectangle

List Box Method


Description Returns the height of an item in the ListBox. Returns the bounding rectangle for an item in the ListBox. Returns a value indicating whether the specified item is selected. Returns the zero-based index of the item at the specified coordinates. Selects or clears the selection for the indicated item in the list box.

ClearSelected

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

73/105

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

74/105

Add Items in ListBox at Design time


Click the corresponding ellipsis () button of the ListBoxs Item s property Type in item/s in the provided textbox

Add/Remove Item in ListBox at Runtime


To add an item in the ListBox at runtime
ListBox1.Items.Add(strString) ListBox1.Items.AddRange(arrItems)

To remove the ListBox in runtime:


ListBox1.Items.Remove(strString) ListBox1.Items.RemoveAt(iItemNo)

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

75/105

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

76/105

Combo Box
Windows Forms Combo Box Control
Combines of a text box and a drop-down list User can enter text or select an item from a drop-down part

Combo Box Properties


Properties Draw Mode Description Returns or sets a value indicating whether your code or the operating system will handle drawing of elements in the list. Returns or sets the height in pixels of the drop-down portion of the ComboBox. Returns or sets a value specifying the style of the ComboBox. Returns or sets the width of the drop-down portion of a ComboBox. Returns or sets a value indicating whether the ComboBox is displaying its drop-down portion.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

Example of a ComboBox
DropDownHeight DropDownStyle DropDownWidth DroppedDown

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

77/105

Working with Windows Forms and Controls

78/105

13

12/11/2013

Combo Box Properties


Properties
IntegralHeight

Combo Box Properties


Properties
SelectedIndex

Description
Return or sets a value indicating whether the control should resize to avoid showing partial items.

Description
Gets or sets the index specifying the currently selected item.

ItemHeight
Items MaxDropdownItems

Returns or sets the height of an Item in the ComboBox.


Returns an object representing the collection of the items contained in this ComboBox. Returns or sets the maximum number if items to be shown in the drop-down portion of the ComboBox.

SelectedT ext
SelectionLength SelectionStart Sorted

Gets or sets the text that is selected in the editable portion of a ComboBox.
Gets or sets the number of characters selected in the editable portion of the ComboBox. Gets or sets the starting index of text selected in the ComboBox. Get or sets a value indicating whether the items in the ComboBox are sorted.

MaxLength

Returns or sets the maximum number of characters possible in the editable portion of a ComboBox.

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

79/105

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

80/105

Combo Box Method


Properties BeginUpdate EndUpdate Description Maintains performance when items are added to the ComboBox one at a time. Resume painting the ComboBox control after painting is suspended by the BeginUpdate method.

Add Item in Combo Box at Design time


Click the corresponding ellipsis () button of the ListBoxs Item s property Type in item/s in the provided textbox

FindString
FindStringExact GetItemHeight Select SelectAll

Finds the first item in the ComboBox that start with the specified string.
Find the first item that exactly matches the specified string Returns the height of an item in the ComboBox. Select a range of text. Select all text in the text box of the combo box.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
81/105

Working with Windows Forms and Controls

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

82/105

Add Item in Combo Box at Design time


Configuring ComboBoxes
ComboBoxStyle.DropDow n

Add/Remove Item in Combo Box at Runtime


To add an item in the ComboBox at runtime
ComboBox1.Items.Add(strString) ComboBox1.Items.AddRange(arrItems)

ComboBoxStyle.Simple ComboBoxStyle.Dropdow nList

To remove the ListBox in runtime:


ComboBox1.Items.Remove(strString) ComboBox1.Items.RemoveAt(iItemNo)

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

83/105

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

84/105

14

12/11/2013

Picture Box
Windows Forms Picture Box Control
Displays graphics in bitmap, icon, JPEG, GIF, or other image formats

Picture Box
Creating a PictureBox.
Add a PictureBox to a form Use the Image property to specify the image to be displayed At design time, select the Image property from the Properties window Click the ellipsis() button

Example of a PictureBox

Click the Import button then select picture from the appearing dialog box. Click Open then click OK to load the selected picture.
Working with Windows Forms and Controls Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
85/105

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

86/105

Picture Box
Creating a PictureBox ( cont..) At runtime, an image can be loaded into the Image property by assigning an Image object to that property. To create an image object from an image file, use the image classFromFile method as follow s:
PictureBox1.Image = Image.FromFile_("c:\vbnet\pictureBox\waterlilies.j pg")
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

Picture Box
Sizing PictureBoxes to Contents
PictureBoxSizeMode.AutoSize PictureBoxSizeMode.Center Image PictureBoxSizeMode.Nor mal PictureBoxSizeMode.StretchImage PictureBoxSizeMode.Zoom

Working with Windows Forms and Controls

87/105

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

88/105

PictureBox Properties
Properties BorderStyle Description Indicates the border style for the control. ImeMode

PictureBox Properties
Properties Description Gets or sets the Input Method Editor (IME) mode supported by this control. Gets or sets a value indicating whether displayed in the PictureBox control while the main image is loading. Gets or sets a value indicating whether controls elements are aligned to support locales using right-to-left fonts. Indicates how the image is displayed. Gets or sets the tab index value. Gets or sets the text of the PictureBox. Gets or sets a value indicating whether an image is loaded synchronously .
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
90/105

DefaultIMEMode
ErrorImage

Gets a value indicating the mode for Input Method Editor (IME) for the PictureBox.
Gets or sets the image to display when an error occurs during the image loading process or if the image load is cancelled. Gets or sets the image that the PictureBox displays.

InitialImage RightT oLeft

Image

SizeMode T abIndex T ext WaitOnLoad

Image Location

Gets or sets the path for the image display in the PictureBox.

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

89/105

Working with Windows Forms and Controls

15

12/11/2013

PictureBox Methods
Methods CancelAsync Dispose Load LoadAsync T oString Description Cancels an asynchronous image load. Releases all resources used by the PictureBox. Displays an image in the PictureBox. Loads an image synchronously . Returns a string that represents the current PictureBox control.

Tool Tip
Windows Forms Tool Tip Control
Small rectangular windows with a yellow background Displays helpful text when the mouse hovers over some visual element in a program.

Example of a Tool Tip

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

91/105

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

92/105

Tool Tip
Creating ToolTips
not created as standard controls at design time
Activ e

ToolTip Properties
Properties Description Gets or sets a value indicating whether the ToolT ip is currently active. Gets or sets the automatic delay for the ToolT ip. Gets or sets the period of time the ToolT ip remains visible if the pointer is stationary on a control with specified ToolT ip text. Gets or sets the background color for the ToolT ip.

Appears in the component tray To assign text to a ToolTip, use this SetToolTip method: ToolTip1.setToolTip(Textbox1, This is a textbox.")

AutomaticDelay AutoPopDelay

BackColor

CreateParams ForeColor
InitialDelay

Gets the creation parameters for the ToolTip window Gets or sets the foreground color for the ToolTip.
Gets or sets the time that passes before the ToolT ip appears.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
94/105

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

93/105

Working with Windows Forms and Controls

ToolTip Properties
Properties IsBalloon OwnerDraw Description Gets or sets a value indicating whether the ToolT ip should use a balloon window. Gets or sets a value indicating whether the ToolT ip is drawn by the operating system or by code that you provide. Gets or sets the length of time that must transpire before subsequent ToolT ip windows appear as the pointer moves from one control to another. Properties CanExtend Dispose Finalize

ToolTip Methods
Description Returns true if the ToolTip can offer an extender property to the specified target component. Releases the resources used by the ToolTip. Releases the unmanaged resources and performs other cleanup operations before the Cursor is reclaimed by the garbage collector. Retrieves the ToolTip text associated with the specified control. Removes all ToolTip currently associated with the ToolTip component.

ReShowDelay

GetT oolTip Remov eAll

SetT oolTip
StopTimer T oString
Working with Windows Forms and Controls Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
95/105

Associates ToolTip text with the specified control.


Stops the timer that hides displayed ToolTips. Returns a string representation
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
96/105

Working with Windows Forms and Controls

16

12/11/2013

Timer
Windows Forms Timer Control
used to create and handle periodic events added to the component tray at design time

Timer
Creating a Timer
add a timer to a form to set how often you want the timer to generate Tick events
set the interval property (milliseconds the default is 100) a code can be executed in a handler for this event each time a T ick event occurs

Example of a Timer

timer use the computers built-in clock timer ticks wont happen faster than 18 ticks per second

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

97/105

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

98/105

Timer Properties
Properties AutoReset Description Gets or sets a value indicating whether the T imer should raise the Elapsed event each time the specified interval elapses or only after the first time it elapses. Gets or sets a value indicating whether the T imer should raise the Elapsed event. Gets or sets the interval at which to raise the Elapsed event. Gets or sets the site that blinds the T ime to its container in design mode. Methods BeginInit

Timer Methods
Description Begins the run-time initialization of a T imer that is used on a form or by another component.

ChangeMode
Close Dispose

Enabled Interv al Site

Changes the start time and the interval between method invocations for a timer.
Releases the resources used by the T imer. Releases all resources used by the current instance of Timer.

EndInit
Start

Ends the run-time initialization of a Timer that is used on a from or by another component.
Starts raising the Elapsed event by setting Enabled to T rue

T ag

Gets or sets an arbitrary string representing some type of user state.


Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

Stop T oString

Stops raising the Elapsed event by setting Enabled to False Returns a string that represents the Timer.
Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
100/105

Working with Windows Forms and Controls

99/105

Working with Windows Forms and Controls

Timer Events
Ev ents Disposed Elapsed Description Adds an event handler to listen to the Disposed event on the component. Occurs when the interval elapses.

Built-in Dialog
Same dialogs used by other Window s application Built-in Dialogs available through Window s controls
Open File Save File Folder Browser Font Color Print Preview Page Setup Print
101/105

Example:
Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Mybased.Load Timer1.enabled = True End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

Label1.Text = Format(Now, "hh:mm:ss")


End Sub End Class
Working with Windows Forms and Controls Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

102/105

17

12/11/2013

Built-in Dialog
allow s the user to specify w hat files to open DialogResult.Abort
DialogResult.Abort DialogResult.Cancel DialogResult.Ignore DialogResult.No DialogResult.None DialogResult.OK DialogResult.Retry DialogResult.Yes
Working with Windows Forms and Controls Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE
103/105

Built-in Dialog
OpenFileDialog
allows the user to specify what files to open Example:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then MessageBox.Show (OpenFileDialog1.FileName) End If End Sub

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

104/105

Built-in Dialog
Save File Dialogs
allow user to give a program the name and/or location of the file where data will be saved

Example:
Pri vat e S ub Bu tto n1 _Cl ick (B yVa l sen der A s S yst em .Ob je ct, ByV al e A s Sys tem .E ven tAr gs ) H an dle s B ut ton 1.C li ck If Sav eFi le Dia log .S how Dia lo g1. Sh owD ial og () = Dia log Res ul t.O K T he n Tex tBo x1. Te xt = S av eFi leD ia log 1. Fil eNa me
End If End Su b

Working with Windows Forms and Controls

Prepared by: Jefferson A. Costales, MIT, IBM-CDA, MCTS, ZCE

105/105

18