Discussion Locked

Propertypage for several properties

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I use Visual Basic to build an ActiveX Control but I don't know how to create a propertypage that can be used for several properties (like StandardColor propertypage).

6 replies

by kgreenwood

In the project explorer window, double-click your control to open the designer, then go to the property window and double-click the PropertyPages property. This will display the Connect Property Pages dialog. You can select the standard property pages from in there.

by tuanna123

No, I don't ask about using standard propertypage. I want to create a propertypage that can be used by several properies (i.e my propertypage can be used like standard propertypage in my project)

by shanghai sam

I assume you already have properties within your class...I'll use an example property called caption (string)
First add the property page (Project|Add Property Page), give it a meaningful name.
Place a textbox (and any other controls you need for each of your properties) onto the page, in this example I will call the textbox txtCaption.

Doublelclick on the page to open the code window where you will see Private Sub PropertyPage_SelectionChanged()

place this code in there
'get the caption of the first control
txtCaption.Text = SelectedControls(0).Caption

The purpose of this event is to get the existing property values from the control or controls that are currently selected, more than one of your control could be selected. You'll have to decide how to handle mutiple selections for each of your properties...use something like this for properties that need to be singular

if selectedcontrols.count > 1 then
txtCaption.enabled=false
else
txtCaption.enabled=true
end if

to set the properties for all selected controls
add this code in the ApplyChanges procedure

dim obj
for each obj in SelectedControls
obj.Caption=txtCaption.txt
next

and then to enable the Apply button
place code in
Private Sub txtCaption_Change()
changed=true
End Sub

now you can this property page as indicated in my previous post

by tuanna123

No, I want my propertypage to be used by several PROPERTIES (not controls). For example, both ForegroundColor and BackgroundColor can use StandardColor propertypage.

This discussion is closed to new replies.