473,508 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Property editor

Hi:

My component has a property which type is control, i want it to accept
only textbox and combobox, how to tell the properties windows, when
drop down or set the property, it only show or accept the textbox and
combobox control ?

Thanks
JCVoon
Nov 21 '05 #1
2 1403
"JC Voon" <jc*******@yahoo.com> schrieb:
My component has a property which type is control, i want it to accept
only textbox and combobox, how to tell the properties windows, when
drop down or set the property, it only show or accept the textbox and
combobox control ?


All you can do (AFAIK) is checking the class name of the assigned value:

\\\
Private m_TheControl As Control

Public Property TheControl() As Control
Get
Return m_TheControl
End Get
Set(ByVal Value As Control)
If TypeOf Value Is TextBox OrElse TypeOf Value Is ComboBox Then
m_TheControl = Value
Else
Throw _
New ArgumentException( _
"The control must be either a textbox or combobox." _
)
End If
End Set
End Property
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #2
Herfried, I noticed us used the ArgumentException Class to throw an
exception. This was new to me and in reading the documentation on it, I am
having trouble understanding the difference between this and just throw new
exception. Is there a real difference in that both can pass an exception
message? I would appreciate your insight as to the difference. Thanks.

"Herfried K. Wagner [MVP]" wrote:
"JC Voon" <jc*******@yahoo.com> schrieb:
My component has a property which type is control, i want it to accept
only textbox and combobox, how to tell the properties windows, when
drop down or set the property, it only show or accept the textbox and
combobox control ?


All you can do (AFAIK) is checking the class name of the assigned value:

\\\
Private m_TheControl As Control

Public Property TheControl() As Control
Get
Return m_TheControl
End Get
Set(ByVal Value As Control)
If TypeOf Value Is TextBox OrElse TypeOf Value Is ComboBox Then
m_TheControl = Value
Else
Throw _
New ArgumentException( _
"The control must be either a textbox or combobox." _
)
End If
End Set
End Property
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #3

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

Similar topics

2
3021
by: Luis Arvayo | last post by:
Is there some way to attach an editor to a property of a class at runtime ? Ex.; public class MyClass { public int BitmapIndex
3
4304
by: Shimon Sim | last post by:
I have control. One of the properties is implemented as StringCollection. I didn't use any Editor attribute for it. During Design time system shows dialog similar to Items in DropDownList but Add...
0
5545
by: Brian Young | last post by:
Hi all. I'm using the Property Grid control in a control to manage a windows service we have developed here. The windows service runs a set of other jobs that need to be managed. The control...
6
1853
by: Altman | last post by:
I would like to use an indexed property to access my private array of user controls. If I don't use an indexed property, the property will show up in my Properties Window during development. Is...
1
3846
by: Friskusen | last post by:
I have (almost) added a simple Toolbar custom control to my control library. The Items on the toolbar are implemented in a class named ToolbarItem. I also use a class ToolbarItemCollection to...
0
817
by: Chris Petchey | last post by:
I am inheriting an existing windows control. I am adding a datasource and datamemberfield properties. However, the existing control already has "datasource" and "datamember" properties so I rename...
0
847
by: --== Alain ==-- | last post by:
Hi, i would like to custom my ListView control by making a particular property editor for ListView.Columns property. Basically, i want to allow use to choose among several types of columns...
0
25482
ADezii
by: ADezii | last post by:
The motivation for this Tip was a question asked by one of our Resident Experts, FishVal. The question was: How to Declare Default Method/Property in a Class Module? My response to the question was...
2
4210
by: R.A.F. | last post by:
Hi, I have a custom control in which i have a collection property named "Columns". this collection property add/remove column objects. in my Column class i have a property named Alignment...
0
870
by: colin | last post by:
Hi, I have my property editor working for my custom classes and struct using typeconverters and generting propertydescriptors for the custom fields and data fields etc, ... when I edit an...
0
7127
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7331
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5633
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5056
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3204
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
424
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.