473,624 Members | 2,496 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

accessing TypeConverter from code

Hello,

I have a TypeConverter for converting between this Enum and Strings.

Public Enum DeviceNameEnum
dnNone
dn2500
dnMirror
End Enum 'DeviceNameEnum

The Strings are "None", "2500", and "Mirror". The conversion works in a
PropertyGrid. How can I access the TypeConverter to convert an instance
of the Enum to the corresponding String to put in a TextBox?
Bill

Jun 15 '06 #1
4 1696
Bill,
You can use something like:

Dim converter As TypeConverter =
TypeDescriptor. GetConverter(Ge tType(DeviceNam eEnum))

To get the converter, be certain to review the parameters to GetConverter...

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
<sw************ @yahoo.com> wrote in message
news:11******** **************@ p79g2000cwp.goo glegroups.com.. .
| Hello,
|
| I have a TypeConverter for converting between this Enum and Strings.
|
| Public Enum DeviceNameEnum
| dnNone
| dn2500
| dnMirror
| End Enum 'DeviceNameEnum
|
| The Strings are "None", "2500", and "Mirror". The conversion works in a
| PropertyGrid. How can I access the TypeConverter to convert an instance
| of the Enum to the corresponding String to put in a TextBox?
| Bill
|
Jun 16 '06 #2
I fixed the problem by also applying the TypeConverterAt tribute
directly to the Enum. Previously, the TypeConverterAt tribute was only
applied to a public property in a class, which is what makes a
PropertyGrid work.
Bill

Jay B. Harlow [MVP - Outlook] wrote:
Bill,
You can use something like:

Dim converter As TypeConverter =
TypeDescriptor. GetConverter(Ge tType(DeviceNam eEnum))

To get the converter, be certain to review the parameters to GetConverter...

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
.NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
<sw************ @yahoo.com> wrote in message
news:11******** **************@ p79g2000cwp.goo glegroups.com.. .
| Hello,
|
| I have a TypeConverter for converting between this Enum and Strings.
|
| Public Enum DeviceNameEnum
| dnNone
| dn2500
| dnMirror
| End Enum 'DeviceNameEnum
|
| The Strings are "None", "2500", and "Mirror". The conversion works in a
| PropertyGrid. How can I access the TypeConverter to convert an instance
| of the Enum to the corresponding String to put in a TextBox?
| Bill
|


Jun 16 '06 #3
I understand the property grid looks at the property first, the type second.

So if you put the typeconverter on only the Enum it should work in both
places.

Although I have not tested the above...

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
<sw************ @yahoo.com> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.com.. .
|I fixed the problem by also applying the TypeConverterAt tribute
| directly to the Enum. Previously, the TypeConverterAt tribute was only
| applied to a public property in a class, which is what makes a
| PropertyGrid work.
| Bill
|
| Jay B. Harlow [MVP - Outlook] wrote:
| > Bill,
| > You can use something like:
| >
| > Dim converter As TypeConverter =
| > TypeDescriptor. GetConverter(Ge tType(DeviceNam eEnum))
| >
| > To get the converter, be certain to review the parameters to
GetConverter...
| >
| > --
| > Hope this helps
| > Jay B. Harlow [MVP - Outlook]
| > .NET Application Architect, Enthusiast, & Evangelist
| > T.S. Bradley - http://www.tsbradley.net
| >
| >
| > <sw************ @yahoo.com> wrote in message
| > news:11******** **************@ p79g2000cwp.goo glegroups.com.. .
| > | Hello,
| > |
| > | I have a TypeConverter for converting between this Enum and Strings.
| > |
| > | Public Enum DeviceNameEnum
| > | dnNone
| > | dn2500
| > | dnMirror
| > | End Enum 'DeviceNameEnum
| > |
| > | The Strings are "None", "2500", and "Mirror". The conversion works in
a
| > | PropertyGrid. How can I access the TypeConverter to convert an
instance
| > | of the Enum to the corresponding String to put in a TextBox?
| > | Bill
| > |
|
Jun 16 '06 #4
I did test it. What you suggest works. The PropertyGrid works if the
TypeConverter is only applied to the Enum, and not to the property.
Bill

Jay B. Harlow [MVP - Outlook] wrote:
I understand the property grid looks at the property first, the type second.

So if you put the typeconverter on only the Enum it should work in both
places.

Although I have not tested the above...

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
.NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
<sw************ @yahoo.com> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.com.. .
|I fixed the problem by also applying the TypeConverterAt tribute
| directly to the Enum. Previously, the TypeConverterAt tribute was only
| applied to a public property in a class, which is what makes a
| PropertyGrid work.
| Bill
|
| Jay B. Harlow [MVP - Outlook] wrote:
| > Bill,
| > You can use something like:
| >
| > Dim converter As TypeConverter =
| > TypeDescriptor. GetConverter(Ge tType(DeviceNam eEnum))
| >
| > To get the converter, be certain to review the parameters to
GetConverter...
| >
| > --
| > Hope this helps
| > Jay B. Harlow [MVP - Outlook]
| > .NET Application Architect, Enthusiast, & Evangelist
| > T.S. Bradley - http://www.tsbradley.net
| >
| >
| > <sw************ @yahoo.com> wrote in message
| > news:11******** **************@ p79g2000cwp.goo glegroups.com.. .
| > | Hello,
| > |
| > | I have a TypeConverter for converting between this Enum and Strings.
| > |
| > | Public Enum DeviceNameEnum
| > | dnNone
| > | dn2500
| > | dnMirror
| > | End Enum 'DeviceNameEnum
| > |
| > | The Strings are "None", "2500", and "Mirror". The conversion works in
a
| > | PropertyGrid. How can I access the TypeConverter to convert an
instance
| > | of the Enum to the corresponding String to put in a TextBox?
| > | Bill
| > |
|


Jun 17 '06 #5

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

Similar topics

2
2191
by: João Santa Bárbara | last post by:
Hi all i have a class that i have made and i made an Typeconverter as well, and my problem is the code genereated in my form is Dim ClassTest1 As TestApplication.ClassTest = New TestApplication.ClassTest Me.MyClassTest = ClassTest1 Wich is quite good, but my problem is in my property browser i cannot change any of my properties
3
1607
by: Norman | last post by:
I have a collection that can have a reference to various types of arrays. String was easy: ... string sPropertyArray = (string)oReturn; foreach( string sItem in sPropertyArray ) { ...
2
3410
by: kw | last post by:
I'm getting different behavior from what I would expect and was hoping someone could clue me in. At run time I need to examine a property of an object for a custom TypeConverter, then use that converter on a value. Here's the deal: object attrs=(object)PropertyInfo.GetCustomAttributes(typeof(TypeConverterAttribu te),false);
5
2180
by: ljlevend | last post by:
Is there a TypeConverter that converts Doubles to percent values in a PropertyGrid? The Windows.Forms.Form.Opacity property seems to use the TypeConverter that I want. Thank you, Lance
0
1190
by: Alex Clark | last post by:
Hi all, Apologies for the cross-post but I can't determine if this is a VS .NET problem or a VB.NET language issue. I'm using .NET 1.1 SP1, VS 2003 EA, VB.NET. I'm coding a custom component which is designed to be dropped onto a form and have it's properties manipulated at runtime. I have a custom implementation of the TypeConverter class called UniversalTypeConverter which inherits from ExpandableObjectConverter, and for the most...
4
2169
by: Kent Boogaart | last post by:
*tried this already on the buildingcontrols newsgroup but didn't get a response* Hi, As far as I can tell, it is not possible to use the TypeConverter infrastructure with generic types. Say you have this type: public struct Id<T> where T : IComparable { ... }
11
2337
by: Rolf Welskes | last post by:
Hello, the problem seems to be complex and is in all developments of web-controls which uses own TypeConverter. For this I have here a simple demo-program of the problem: The Control-code: A class MyString which is a class which is similar to a string public class MyString {
1
2153
by: --== Alain ==-- | last post by:
Hi, I 'm facing an interesting issue regarding a property and its TypeConverter. When i do not attach a TypeConverter to this property, all custom properties of my custom control are displayed in Test Container. Since i attached this TypeConverter to my property, ALL custom properties (properties implemented by myself) are not displayed in Test Container.
6
3889
by: Larry Smith | last post by:
Hi there, Can anyone provide any insight on why MSFT introduced "TypeConverter.GetProperties()". There are two classes for dealing with metadata in .NET, 'Type" and "TypeDescriptor". Each has a "GetProperites()" method so why complicate the situation even more than it already is by adding a "GetProperties()" method to "TypeConverter". The class is supposed to be for converting types so "GetProperties()" seems misplaced and redundant (as...
0
8240
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
8175
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8625
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
6111
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
5565
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
4082
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
4177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2610
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
1487
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.