473,379 Members | 1,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Adding a property to an inherited tool

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
Nov 20 '05 #1
4 896
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" <an*******@discussions.microsoft.com> wrote in message
news:1e*****************************@phx.gbl:
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


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.3.0 - Release Date: 6/12/2004
Nov 20 '05 #2
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/de...ngpropgrid.asp

http://msdn.microsoft.com/library/de...etpropbrow.asp

Hope this helps
Jay
"Tom" <an*******@discussions.microsoft.com> wrote in message
news:1e*****************************@phx.gbl...
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

Nov 20 '05 #3
Tom
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?
Nov 20 '05 #4
* "Tom" <an*******@discussions.microsoft.com> scripsit:
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 ;-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: James Geurts | last post by:
Hey all... I posted this in the vs.net ide group too, but people are not answering, so I figured that it might be more appropriate here. I'm not sure if I'm adding a designer to my code properly. ...
10
by: Jacob | last post by:
Is there a way to make a property of an inherited class invisible to the programmer? I know that using the keyword "new" allows you to create another property in the place of the existing one, but...
4
by: Richard Abraham | last post by:
I have created a new class ServiceTimer based upon the .NET System.Timers.Timer class. This has a new property CollectionIntervalMinutes which I expected to be added to the 'Behavior' section of the...
8
by: TS | last post by:
I am trying to get set a property of a control on the inherited class from base class. I imagine i have to use reflection, so could someone give me the code to do it? something like this?...
9
by: Ken Dopierala Jr. | last post by:
Hi, I'd like to add a tool tip to buttons on my form. I can't find a tooltip property though in the design-time properties box. Where can I create tool tips for buttons and other controls? ...
12
by: cjobes | last post by:
Hi all, I'm trying to create a dataset as a component to make it accessable from all forms. I have used that following code so far in the component designer: Inherits...
15
by: Sam Kong | last post by:
Hello! I got recently intrigued with JavaScript's prototype-based object-orientation. However, I still don't understand the mechanism clearly. What's the difference between the following...
0
by: AndyL69 | last post by:
Hello I've got a very strange Problem. When im adding a new ACE entry to a UNC Direcotry the inherented ACL's will be lost. When I'm adding a new ACE to a directory / file in this UNC path the...
3
by: Doc John | last post by:
I have a windows Form that inherits from Base_form. In Base_form I added a panel that covers the whole Form (panel1.Dock = Fill). The problem is that all the controls in the Form that inherit...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.