473,667 Members | 2,577 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 1419
"JC Voon" <jc*******@yaho o.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 ArgumentExcepti on( _
"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 ArgumentExcepti on 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*******@yaho o.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 ArgumentExcepti on( _
"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
3029
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
4312
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 button throws an error "Constructor on type System.String not found.". I may understand this message - there are too many contractor and non of them takes string. But how can I fix the problem or may be use the editor similar to Font.Names...
0
5561
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 is used to view the state of the running jobs and schedule new jobs. The control also runs in the context of Internet Explorer (we do this so the administrators of the jobs can always receive the latest control). The property grid is used to...
6
1865
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 there a way to get this to show up in the properties window?
1
3850
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 manage ToolbarItems. The Toolbar control has a property Public ReadOnly Property Items() as ToolbarItemCollection This setup is very similar to the standard ListView control which uses a ColumnHeaderCollection to manage ColumnHeaders.
0
821
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 my properties to "MyDataSource" and "MyDataMember" so as not to confuse with the originals (which are still required and nothing to do with this addition) I wish to use the "Editor" attributes to allow assignment of the values to these...
0
855
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 (with checkboxes, with progressbars, only text, with images,..) for that i thought it could be good to create a special property editor for Columns (columnheadercollection type).
0
25557
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 inadequate to say the least, but I was determined to come up with the correct answer, especially since my primary background is Visual Basic, and I knew that there was an answer. Well, I did come up with an answer and I decided to incorporate it into...
2
4221
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 which use a custom property editor. when this property editor is not linked to this property,
0
882
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 element of an array of struct eg Vector3 with the pop up collection editor it passes the changed notification to update the array in the top class. but it doesnt do this when I edit an element of the vector3 array
0
8457
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8883
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8788
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6203
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5675
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4200
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1778
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.