Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom Control Properties

Status
Not open for further replies.

DMAN3021

Programmer
Aug 20, 2002
40
CA
Yellow all,

I'm building my first VB custom control (yey!) and its moving a long nicely, but I need to specify certain states that this control will be in, and I would like for these states to be displayed as properties (in the property window) and to be modifiable by code.

So, the question is, how do I add properties to the control itself. I guessed that I would need a global variable to indicate which state I am in, but I would need to publish it to the properties of the control. How would I do this?

Thanks,

Dman...
 
Its preferred to use private variables. Say you want a property called "Text"

Create a private module-level variable in your control called mText.

Next, type out "Public Property Text As String." Then press enter. The IDE will fill out the get and set parts for you. Inside those parts, you will want to return your mText value and set your mText value. They will then show up in the property window.
 
within the custom sontrol class refer to the private variabels, that will increase the speed.

and try using enums to fill the properties

something like

Code:
dim _options as myenum


enum myenum
 option1
 option2
end enum

public property options() as myenum

Christiaan Baes
Belgium

What a wonderfull world - Louis armstrong
 
Oh, and say I want to create my own type. For example, my control has different statuses (On, Off, Busy), how can I create a property that gives those types?

Dman...
 
Oh! there it is,

sorry, I poked around and found out that you had answered my question all along!

Wooohhooo! thanks all!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top