VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

Systems Analysis - System analysis and Design tutorial for Software Engineering

You are here: Visual Basic > Advanced VB6 tutorial > Chapter 13

Using the SelectionChanged Event to Detect When the Developer Begins to Edit Properties

The SelectionChanged event of a Property Page happens when

  • The Property Page displays.

  • There is a change in the selected controls (the SelectedControls collection) while the Property Page is displayed.

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.


Private Sub PropertyPage_SelectionChanged()

   chkIsFahrenheit.Value = _

   If SelectedControls.Count > 1 Then
      txtTempDate.Enabled = False
      txtTempDate.Text = _
   End If

End Sub


<< Previous | Contents | Next >>

Home | About Us | Privacy Policy | Contact Us

Copyright © | All Rights Reserved