Presentation is loading. Please wait.

Presentation is loading. Please wait.

Group Boxes, Radio buttons and Checked List Boxes

Similar presentations


Presentation on theme: "Group Boxes, Radio buttons and Checked List Boxes"— Presentation transcript:

1 Group Boxes, Radio buttons and Checked List Boxes
2.2 Working with Controls Group Boxes, Radio buttons and Checked List Boxes 02/07/2019

2 Learning Objectives Know what radio buttons, checked list boxes and group boxes are used for; and how to use them. 02/07/2019

3 The Radio Button Used to allow the user to select one option from two or more options e.g. 02/07/2019

4 The Radio Button Properties Events
Apart from the Name and Text properties the most useful property is Value. It holds true if selected or False if not. Events The click event is the only one you are likely to use. 02/07/2019

5 The Checked List Box Similar to the radio button in that you can test its Value property to see if it is selected. Unlike the radio button you can select more than one at a time. 02/07/2019

6 The Checked List Box A common use of a checked list box is setting general default values through the Tools/Options menu. Has similar properties and methods to the radio button. 02/07/2019

7 The Group Box The group box is a rectangular shape in which you usually place other controls. The last picture for example shows a group box named Window options. 02/07/2019

8 The Group Box Advantages are:
Can reposition all controls at design time by just moving the group box. Can show or hide all the controls inside it at run-time by just showing or hiding the group box (Visible property). If you want two or more groups of radio buttons, so that one can be selected from each group, then you must put each group into a group box. Without group boxes you could only select one button from all the buttons on the form. 02/07/2019

9 Program 2.2 Radio buttons, group boxes and checked list boxes
Specification: Demonstrate the use of two groups of radio buttons and a checked list box. Create a new project named ‘Forms’. Change the Form’s Text property to ‘Radio buttons, checked list and group boxes’. 02/07/2019

10 Program 2.2 Radio buttons, group boxes and checked list boxes
Drag a GroupBox control from the toolbox and position and size it as shown. Drag and place two RadioButton controls from the ToolBox straight into the GroupBox as shown. 02/07/2019

11 Note I suggest that when you change the Text properties of any controls you also change the Bold property to True. To save space in the following instructions I have not stated this every time. 02/07/2019

12 Program 2.2 Radio buttons, group boxes and checked list boxes
Change the Text property of the GroupBox control to ‘Gender’. Change the Name property of the first RadioButton control to ‘radMale’ and its Text property to ‘Male’. Change the Name property of the second RadioButton control to ‘radFemale’ and its Text property to ‘Female’. 02/07/2019

13 Note If you had first placed the RadioButtons outside the GroupBox and then moved them into the GroupBox, they would not belong to it. You must drag them straight from the ToolBox into the GroupBox. Try moving the GroupBox and both RadioButtons should move with it. 02/07/2019

14 Program 2.2 Radio buttons, group boxes and checked list boxes
Place a Label below the GroupBox. Set its Name property to lblSelection, its BorderStyle property to FixedSingle and its Text property to blank. Double click the Male radio button. Type the following code in the procedure code template: lblSelection.Text = “You selected Male” 02/07/2019

15 Program 2.2 Radio buttons, group boxes and checked list boxes
Return to Design view. Double click the Female radio button. Type the following code in the procedure code template: lblSelection.Text = “You selected Female” Run the program and test the two RadioButtons. 02/07/2019

16 Program 2.2 Radio buttons, group boxes and checked list boxes
Place another GroupBox control to the form and change its Text property to Age as shown on the next slide. Place three RadioButtons controls in this GroupBox. Keep their default names but change their Text properties as shown on the next slide. 02/07/2019

17 Program 2.2 Radio buttons, group boxes and checked list boxes
02/07/2019

18 Program 2.2 Radio buttons, group boxes and checked list boxes
Run the program and test the fact that you can select one RadioButton from each of the two groups (remember this is why we use GroupBoxes, otherwise you would only be able to choose one RadioButton from both groups). Place a third GroupBox control on the frame and change its Text property to Replies as shown on the next slide. 02/07/2019

19 Program 2.2 Radio buttons, group boxes and checked list boxes
Place a CheckedListbox in the GroupBox and set its Items property as shown. 02/07/2019

20 Program 2.2 Radio buttons, group boxes and checked list boxes
Run the program and test thoroughly. Save the program. Publish the program. 02/07/2019

21 Extensions Add another label below the Age group box to indicate which of the radio buttons is currently selected. Make the age group box and the label above invisible when the program runs. When the user first selects a gender option make the group box and label appear. 02/07/2019

22 Plenary What are radio buttons used for?
Allow a user to select one option only from a list. What are group boxes used for? Hold groups of controls. 02/07/2019

23 Plenary What would happen if we didn’t place radio buttons (or other controls) in a group box? It would not be possible to select more than one radio button on a form. You would not be able to move groups of controls at once. 02/07/2019

24 Plenary What is the difference between radio buttons and checked boxes? You can only select one radio button from a group. You can select as many checked boxes as you like. 02/07/2019


Download ppt "Group Boxes, Radio buttons and Checked List Boxes"

Similar presentations


Ads by Google