Freetutes.com

VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

VB .NET - Learn Visual Basic .NET

Systems Analysis - System analysis and Design tutorial for Software Engineering


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

Determining which Controls Are Selected for Editing with the SelectedControls Collection

You'll recall that you can select multiple controls when designing a VB application by holding the Ctrl key and clicking the mouse on successive controls in the same container. You can also select multiple controls in the same physical area of the container by using the "lasso" method: holding down the mouse button outside any control on the container and keeping it down while you "lasso" or mark an area holding several controls (a rectangle of dotted lines appears around the lassoed area).

It's therefore possible that the developer could have selected more than one control when your Property Page is active. In order for you to detect which controls the developer has currently selected, the SelectedControls collection is available in the code of a Property Page. It contains all controls currently selected by the developer. The SelectedControls collection is zero-based. That is you would denote the first element of SelectedControls in your code by:

SelectedControls(0)

The SelectedControls collection has a Count property to tell you how many controls are in the collection. Since SelectedControls is zero-based, you would denote the last control in the collection by:

SelectedControls(SelectedControls.Count - 1)

You can refer to the property settings of one of the controls in SelectedControls with the normal object.property syntax, as in this example:

SelectedControls(0).Backcolor

Normally you'll use the SelectedControls collection at the following places in your Property Page's code:


  

<< Previous | Contents | Next >>

Home | About Us | Privacy Policy | Contact Us

Copyright © Freetutes.com | All Rights Reserved