|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
accessing TypeConverter from codeHello,
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 Bill,
You can use something like: Dim converter As TypeConverter = TypeDescriptor.GetConverter(GetType(DeviceNameEnum)) To get the converter, be certain to review the parameters to GetConverter... -- Show quoteHide quoteHope this helps Jay B. Harlow [MVP - Outlook] ..NET Application Architect, Enthusiast, & Evangelist T.S. Bradley - http://www.tsbradley.net <swartzbill2***@yahoo.com> wrote in message news:1150412009.308729.175030@p79g2000cwp.googlegroups.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 | I fixed the problem by also applying the TypeConverterAttribute
directly to the Enum. Previously, the TypeConverterAttribute was only applied to a public property in a class, which is what makes a PropertyGrid work. Bill Jay B. Harlow [MVP - Outlook] wrote: Show quoteHide quote > Bill, > You can use something like: > > Dim converter As TypeConverter = > TypeDescriptor.GetConverter(GetType(DeviceNameEnum)) > > 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 > > > <swartzbill2***@yahoo.com> wrote in message > news:1150412009.308729.175030@p79g2000cwp.googlegroups.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 > | 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... -- Show quoteHide quoteHope this helps Jay B. Harlow [MVP - Outlook] ..NET Application Architect, Enthusiast, & Evangelist T.S. Bradley - http://www.tsbradley.net <swartzbill2***@yahoo.com> wrote in message news:1150469762.497314.221940@i40g2000cwc.googlegroups.com... |I fixed the problem by also applying the TypeConverterAttribute | directly to the Enum. Previously, the TypeConverterAttribute 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(GetType(DeviceNameEnum)) | > | > 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 | > | > | > <swartzbill2***@yahoo.com> wrote in message | > news:1150412009.308729.175030@p79g2000cwp.googlegroups.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 | > | | 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: Show quoteHide quote > 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 > > > <swartzbill2***@yahoo.com> wrote in message > news:1150469762.497314.221940@i40g2000cwc.googlegroups.com... > |I fixed the problem by also applying the TypeConverterAttribute > | directly to the Enum. Previously, the TypeConverterAttribute 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(GetType(DeviceNameEnum)) > | > > | > 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 > | > > | > > | > <swartzbill2***@yahoo.com> wrote in message > | > news:1150412009.308729.175030@p79g2000cwp.googlegroups.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 > | > | > |
Refer to TableAdapter data in code?
Expose Form Properties and it Controls Properties. How to Send an SMS URI IsFile How to get Windows XP Edition? List Box Population Parameter description Wlan - VB.NET Updating a DataSet while using DataGridView "Optional ByVal SomeDate As Date = Nothing" in VB2005 |
|||||||||||||||||||||||