The
SelectionChanged event of a Property Page happens when
You therefore use the SelectionChanged event procedure to set
the values of Property Page elements that reflect property values. Typical code in the
SelectionChanged event procedure will check the values of properties in the first
control of the SelectedControls collection (SelectedControls(0))
and adjust Property Page elements accordingly, as we do in the example of Listing 13.18.
It's not appropriate to allow some properties to change to a single
value for multiple controls. For instance, the Caption properties of most controls should
be unique to each control. Therefore, you might want to use the SelectionChanged
event procedure to control which properties can change when the developer has selected multiple
controls.
Notice that in Listing 13.18, we check the value of SelectedControls.Count
to see whether the developer has selected multiple controls. If so, we disable the Property Page
elements that correspond to property values that we don't want to set for multiple
controls. If, on the other hand, only one control has been selected, we enable its corresponding
Property Page element and assign to that element the value of the property from the selected
control.
LISTING 13.18
ADJUSTING PROPERTY PAGE ELEMENTS IN THE SELECTIONCHANGED
EVENT PROCEDURE
Private Sub PropertyPage_SelectionChanged()
chkIsFahrenheit.Value = _
SelectedControls(0).IsFahrenheit
If SelectedControls.Count > 1 Then
txtTempDate.Enabled = False
Else
txtTempDate.Text = _
SelectedControls(0).TempDate
End If
End Sub