Microsoft Visual Basic 2010 Step by Step eBook

(Tina Meador) #1

82 Part I Getting Started with Microsoft Visual Basic 2010


radio buttons, each operating independently of one another. For each group that you want
to construct, simply create a group box object first and then add radio buttons one by one to
the group box.

In the following exercise, you’ll create a simple program that uses GroupBox, RadioButton,
and PictureBox controls to present three graphical ordering options to a user. Like the
CheckBox control, the RadioButton control is programmed by using event procedures
and program code, with which you’ll also experiment. Give it a try now.

Gather input with the GroupBox and RadioButton controls


  1. On the File menu, click Close Project to close the Check Box project.

  2. On the File menu, click New Project.


The New Project dialog box opens.


  1. Create a new Visual Basic Windows Forms Application project named MyRadioButton.


The new project is created, and a blank form appears in the Designer.


  1. In the Toolbox, expand to the Containers tab and click the GroupBox control.

  2. Create a medium-sized group box on the top half of the form.

  3. Return to the Toolbox, scroll up to the Common Controls tab, and click the RadioButton
    control.

  4. Create three radio button objects in the group box.


It is handy to double-click the RadioButton control to create radio buttons. Notice that
each radio button gets its own number, which you can use to set properties. Your form
should look about like this:
Free download pdf