Adding a property to an inherited tool

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

I'm making a new class: "validatedTextBox" which is based
on the textBox tool. I need to add several properties to
it that can be set in the properties window of the IDE
when I put the new textbox on a form. I have figured out
how to do this, but would like to know how I can make one
of these properties have a drop-down list in the
properties window that gives just the few valid choices
for the property
(e.g. "integer", "real", "date", "phonenumber")

Thanks
 
Hi,

Use an enum. Here is an example.


Public Enum DrawWidth
Thin = 2
Normal = 5
Wide = 8
End Enum


Public Property LineWidth() As DrawWidth
Get
Return mLineWidth
End Get
Set(ByVal Value As DrawWidth)
mLineWidth = Value
Invalidate()
End Set
End Property

Ken
----------------------
 
Tom,
The easiest way is to make that property a Enum

Public Enum ValidChoice
Integer
Real
Date
PhoneNumber
End Enum

Public Class ValidatedTextBox
Inherits TextBox

Public Property ValidChoice() As ValidChoice
Get ...
Set ...
End Property

End Class

For more advanced features check out the following articles:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/usingpropgrid.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/vsnetpropbrow.asp

Hope this helps
Jay
 
Thank you. Your solutions worked perfectly.

By the way, as this is the first time I've written into a
discussion forum I am unsure of the etiquette. (I have
searched and read them for many years.) Is writing a thank
you proper, or am I just adding unnecessary extra traffic
to the forum?
 
* "Tom said:
Thank you. Your solutions worked perfectly.

By the way, as this is the first time I've written into a
discussion forum I am unsure of the etiquette. (I have
searched and read them for many years.) Is writing a thank
you proper, or am I just adding unnecessary extra traffic
to the forum?

It's always nice to hear a thank you ;-).
 
Back
Top