Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using Option Buttons. Option Buttons Are similar to checkboxes. Must appear in groups. Only one button in the group can be selected at a time. Sometimes.

Similar presentations


Presentation on theme: "Using Option Buttons. Option Buttons Are similar to checkboxes. Must appear in groups. Only one button in the group can be selected at a time. Sometimes."— Presentation transcript:

1 Using Option Buttons

2 Option Buttons Are similar to checkboxes. Must appear in groups. Only one button in the group can be selected at a time. Sometimes called radio buttons.

3 There are three steps involved: 1. Create a frame to group the option buttons. 2. Create the option buttons in the frame. 3. Write code to use the option buttons.

4 Creating a Frame Control What is a Frame Control? Is a container for other controls. The controls that you place inside a frame are treated as one unit. If you move the frame, the controls in the frame move with it. If you delete the frame, the controls in the frame are deleted along with the frame.

5 Important Note! It is important to create a frame that will contain the option buttons before you create the option button themselves.

6 Option Group Are option buttons in a frame!

7 Two Frame Properties! The name property allows you to associate a name with the object in Visual Basic. The caption property specifies the text that will appear at the top of the frame.

8 Example Program! Open VB and create the following screen.

9 Double click the Frame control from the toolbox. A frame appears in the center of the form. Change the Name property of the frame to fraPlanets and change the Caption property to Choose a planet.

10 Creating Option Buttons in the Frame Important: When you create option buttons, click the Option Button tool from the toolbox and drag within the frame to create the option button. If you double click the Option Button tool, the option button that is created will not be associated with the frame, even if it appears to be in the frame.

11 Click the Option Button control from the toolbox. Position the mouse pointer inside the frame. Drag to draw an option button inside the frame about ¼ inch tall and 1 ½ inches wide (1215 x 244). Create three more identical option buttons inside the frame.

12 Option buttons need to be named! Use the Name property to name your buttons. The caption property of an option button is similar to the Caption property of a checkbox. The caption property specifies the text for the attached label.

13 Select the first option button. Change the Name property to optMars and change the Caption property to Mars. Set the properties of the remaining option buttons as follows: NameCaption optJupiterJupiter optSaturnSaturn optPlutoPluto

14 Run the program. Click each of the option buttons to see that they are operating correctly. End and save the program. We will continue tomorrow!

15 HOMEWORK! Pick up your worksheet before you leave.


Download ppt "Using Option Buttons. Option Buttons Are similar to checkboxes. Must appear in groups. Only one button in the group can be selected at a time. Sometimes."

Similar presentations


Ads by Google