Chapter 7 Lesson #14 Group Box Control

advertisement
Chapter 7
Lesson #14
Group Box Control:
A Group Box is simply a container that holds other controls.
The Group Box Properties are:
Name:
Name used to identify the Group Box
Prefix for a Group Box is grp
Text:
Title at the top of the Group Box
Font:
Sets the font properties
BackColor: Sets the background color
ForeColor: Sets the color of the title text
Left, Top, Width, Height: All the same as other controls
Enabled:
Determines whether all controls in the box will respond
to user events.
Visible:
Is the box and all controls in it visible
There are a number of advantages to putting controls in a group box
1. The controls in the Group Box will share the box's BackColor,
ForeColor and Font properties.
2. You can enable and disable all of the controls in the Group Box
by enabling or Disabling the Group Box.
3. You can make all of the controls visible or non-visible by
setting the Visible property of the Group Box.
4. You can move all of the controls in the Group Box by moving
the box.
Note: While the BackColor, ForeColor and Font properties of individual
controls in the Group Box will be set with the box's properties, you can also
change the individual controls properties to suit your needs. So if you
change the Group Box's BackColor property, all of the controls in the box
will inherit that property, but you can then go in and change the BackColor
property of any controls in the box to suit your needs.
Moving the Group Box: To move a group box you must first click on the
box to select it, then a handle will appear looks like crossed arrows pointing
up/down and left/right. Grab that handle to move the Group Box and
associated controls inside the box.
Placing controls in a Group Box:
 If the Group Box is selected and you click on a control in the
toolbox to place it on the form it will appear in the Group Box.
 You can draw a control directly inside the Group Box.
 You can draw a control outside the Group Box and then drag it
inside and drop it.
 You can copy and paste controls into the group box, first copy
the control, then select the Group Box, then paste and the
control will appear inside the box.
Note: To be sure that your controls are inside the Group Box, you
can move the Group Box, if your control moves with it then it is
inside the Group Box.
A tip: If your Group Box is where you want it but you want to check
to see if the controls are inside it, move the Group Box to see if the
controls move with the box, then hit ctrl-Z to undo the move and put
the Group Box back where it was.
Check Box Control:
The Check Box control provides a way to select one or more things from a
group of items.
An example would be if you where writing a program to be used in an ice
cream shop, you would need to be able to select which toppings the
customer has ordered, there could be none, one, or any number to all of
the toppings that you have available.
Check Boxes are usually put into Group Boxes to make it easier to move
them around and to literally group them together in one place.
Properties:
Name:
Name used to identify the control
Prefix for a Checkbox is chk
Text:
Text next to the check box
TextAlign: How the displayed text is positioned
Checked:
Is the box checked (True) or unchecked (False)
Font, BackColor,ForeColor, Left, Top, Width, Height: All the same as
other controls we have discussed
Enabled:
events
Determines whether the check box can respond to user
Visible:
run mode
Determines whether the check box control is visible in
Note: When the check box is in a group box the Left and Top
properties are the position of the check box in the Group Box, not on
the form.
Events:
The only event we are going to be using is...
CheckedChanged: This event is triggered each time the Checked
property of the control changes state.
Radio Buttons:
A Radio Button offers a way to make ONE choice from a list of options.
You can use Radio buttons to select the background color of a form, you
can have a list of as many choices as you want, but the user can only have
one selected at a given time.
Radio buttons always work in groups and each group must be in its own
Group Box
Properties:
Name:
Used to identify the Radio Button
Prefix for the Radio Button is rdo
Text:
Identifying text next to the Radio Button
TextAlign: Specifies how the displayed text is to be aligned
Checked: Indicates if the Radio Button is Selected (True) or NotSelected (False)
Font, BackColor, ForeColor, Left, Top, Width, Height, Enabled,
Visible:
All work as other controls
Note: Just like the Check Box control, if the Radio Button is in a
Group Box, then the Top and Left properties refer to the position
inside the box, not on the form.
Note: When you are setting up your program and you make a group of
Radio Buttons in a Group Box control you should always have one and only
one of the Radio Buttons Checked properties set to True as a default.
Events:
Again, the only Event we are going to use is...
CheckChanged: This event executes when the Checked property
state changes.
Note: When the Checked property of a Radio Button in a group is set to
True, the Checked property of ALL other Radio Buttons in that group is set
to False. This is done automatically by Visual BASIC, you do not have to
write any code to make it happen.
Download