14

Click here to load reader

IMS 3253: Controls 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Check Boxes Radio Buttons Date Time Picker Masked

Embed Size (px)

DESCRIPTION

IMS 3253: Controls 3 Dr. Lawrence West, MIS Dept., University of Central Florida Radio Buttons Radio buttons belong to a group –All buttons directly on the face of the form belong to the same group –All radio buttons in the same group box are in the same group Only one button in a group may be pressed at a time Selecting one in a group unselects all others –All button CheckChanged events execute The Checked property indicates whether checked or not

Citation preview

Page 1: IMS 3253: Controls 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Check Boxes Radio Buttons Date Time Picker Masked

IMS 3253: Controls

1Dr. Lawrence West, MIS Dept., University of Central [email protected]

Topics

• Check Boxes• Radio Buttons• Date Time Picker• Masked Text Box• List Boxes• Combo Boxes• Spinner Control

“Those parts of a computer you can hit with a hammer are called hardware; those program instructions you can only curse at are called software”

Unknown

Page 2: IMS 3253: Controls 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Check Boxes Radio Buttons Date Time Picker Masked

IMS 3253: Controls

2Dr. Lawrence West, MIS Dept., University of Central [email protected]

Check Boxes

• Check boxes enable the user to indicate a single “Boolean” (Yes or No) state by checking or unchecking the box

• The control’s Checked property will be read as either True or False

• The CheckChanged event executes if the box state is changed by the user or in code

• The Text property provides a label and a hot key– Selecting the hot key toggles the checked status

of the box• All check boxes act independently

Page 3: IMS 3253: Controls 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Check Boxes Radio Buttons Date Time Picker Masked

IMS 3253: Controls

3Dr. Lawrence West, MIS Dept., University of Central [email protected]

Radio Buttons

• Radio buttons belong to a group– All buttons directly on the face of the form belong

to the same group– All radio buttons in the same group box are in the

same group• Only one button in a group may be pressed at a

time• Selecting one in a group unselects all others

– All button CheckChanged events execute• The Checked property indicates whether checked

or not

Page 4: IMS 3253: Controls 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Check Boxes Radio Buttons Date Time Picker Masked

IMS 3253: Controls

4Dr. Lawrence West, MIS Dept., University of Central [email protected]

Date Time Picker Control

• Presents a calendar that lets user find a date easily

• Value property contains the selected date, including the current time as a datetime data type

• Text property is a string representation of the Value (not available at design time)

• Default Value is current system clock time• May set value in code• Other date formats are available• ValueChanged event is the default event• Very useful with date-time functions (later)

Page 5: IMS 3253: Controls 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Check Boxes Radio Buttons Date Time Picker Masked

IMS 3253: Controls

5Dr. Lawrence West, MIS Dept., University of Central [email protected]

Masked Text Box

• Provides various predefined as well as custom formats to force user input into a “mask”

• Typing forces characters into available mask spaces

• Control also validates input– No letters allowed in the Phone Number mask

• Selecting control and thenproperties arrow gives quick access to mask dialog– Many controls have this quick access feature

Page 6: IMS 3253: Controls 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Check Boxes Radio Buttons Date Time Picker Masked

IMS 3253: Controls

6Dr. Lawrence West, MIS Dept., University of Central [email protected]

Masked Text Box (cont.)

Page 7: IMS 3253: Controls 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Check Boxes Radio Buttons Date Time Picker Masked

IMS 3253: Controls

7Dr. Lawrence West, MIS Dept., University of Central [email protected]

Masked Text Box (cont.)

• TextMaskFormat propertydetermines if mask charactersare included in the Text property of the control– Default is IncludeLiterals (they are)– You may wish to use ExcludePromptAndLiterals

• Same behavior for CutCopyMaskFormat property

Page 8: IMS 3253: Controls 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Check Boxes Radio Buttons Date Time Picker Masked

IMS 3253: Controls

8Dr. Lawrence West, MIS Dept., University of Central [email protected]

List Boxes and Como Boxes

• All of the properties and methods illustrated in code for the list box form work on combo boxes as well– Reading– Adding & removing items– Setting selected item

• Code• User selection

– Sorting• Text property gives access to current text

Page 9: IMS 3253: Controls 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Check Boxes Radio Buttons Date Time Picker Masked

IMS 3253: Controls

9Dr. Lawrence West, MIS Dept., University of Central [email protected]

Adding List Items at Design Time

• Add the control• Select the Items property in property window OR

Select the properties arrow on the control & choose “Edit Items”

• Add one item per line in the edit window– These items will

be the initial contents of the list or combo

Page 10: IMS 3253: Controls 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Check Boxes Radio Buttons Date Time Picker Masked

IMS 3253: Controls

10Dr. Lawrence West, MIS Dept., University of Central [email protected]

Adjusting List Items at Run Time

• ControlName.Items.Add(value)– Adds value to the end of the list

• ControlName.Items.Insert(index, value)– Adds the value into the list position specified by index

– Other items are pushed upwards to make room• ControlName.Items.RemoveAt(index)

– Removes the item in the index location– Other items are moved downward to fill in

Page 11: IMS 3253: Controls 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Check Boxes Radio Buttons Date Time Picker Masked

IMS 3253: Controls

11Dr. Lawrence West, MIS Dept., University of Central [email protected]

List Items Properties

• ControlName.Items.Count– Number of items in the list (1-based counting)

• .SelectedIndex– Index in the list of the item that is selected– Zero-based numbering

• If there are five items in the list– The .Count property = 5– The items are indexed as 0 – 4– This approach is used for any collection in .Net

Page 12: IMS 3253: Controls 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Check Boxes Radio Buttons Date Time Picker Masked

IMS 3253: Controls

12Dr. Lawrence West, MIS Dept., University of Central [email protected]

List & Combo Box Behavior

• List and Combo boxes will add vertical scroll bars when needed—allow enough width if contents are wide

• List boxes and Simple combo boxes are always open

• List boxes and DropDownList style combo boxes do not allow users to type in a value—must select

• DropDown and Simple style combo boxes allow the user to enter a value not in the list

Page 13: IMS 3253: Controls 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Check Boxes Radio Buttons Date Time Picker Masked

IMS 3253: Controls

13Dr. Lawrence West, MIS Dept., University of Central [email protected]

Group Boxes

• Uses– Provide visual grouping of controls with a common

caption– Allow a group of controls to be enabled or disabled

or turned visible or invisible in one step– Allow you to create multiple independent groups of

radio buttons• Text property labels the group box

– I suggest a leading and trailing space so frame doesn’t pinch the text

Page 14: IMS 3253: Controls 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Check Boxes Radio Buttons Date Time Picker Masked

IMS 3253: Controls

14Dr. Lawrence West, MIS Dept., University of Central [email protected]

Numeric UpDown (Spinner) Control

• Allows user to select a numeric value using the up/down arrows

• Useful properties:– Value—currently displayed number– Maximum and Minimum—smallest and largest

values spinner will reach– Decimal places– Increment

• ValueChanged is most useful event

Use together to create a fractionally incrementing spinner