|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
converting a string to it's enum (integer) equivalentI have a class that exposes the Microsoft.DirectX.Direct3D.Compare property, which allows a drop-down list of values (such as Never, Always etc) to be selected via the propertygrid. I write the string value ("Never", "Always" etc) to an XML file, and when I read back the XML file and set the property I want to be able to set it via the string. This is my property: <TypeConverter(GetType(Microsoft.DirectX.Direct3D.Compare))> _ Public Property AlphaFunction() As Microsoft.DirectX.Direct3D.Compare Get Return _properties(PropertiesList.AlphaFunction) End Get Set(ByVal value As Microsoft.DirectX.Direct3D.Compare) _properties(PropertiesList.AlphaFunction) = value End Set End Property What do I need to do to be able to set this property via it's string value, but still return a drop-down list within a propertygrid to allow the value to be selected by its name? e.g. myclass.AlphaFunction = "Never" Thanks, Richy Richy wrote:
> What do I need to do to be able to set this property via it's string You don't need to.> value, but still return a drop-down list within a propertygrid to allow > the value to be selected by its name? Convert the given String value into the Enum value that it represents, something like: myclass.AlphaFunction _ = CType("Never", Microsoft.DirectX.Direct3D.Compare) HTH, Phill W. Thanks. If I do that, however, I get
Conversion from String "Never" to type Integer is not valid. But I just found I can do it this way: [Enum].Parse(GetType(Microsoft.DirectX.Direct3D.Compare), "Never") Cheers, Richy
Resetting the value of a System.Web.UI.HtmlControls.HtmlInputFile
Order of events, databinding, and UserControls Ayuda contra unos programadores de Linux y PHP que me quieren dañar un negocio Really puzzled (or maybe just totally confused) about VB.NET and ADO.NET AppStartup "Cancel" leaves splash form loaded Stepping through datagridview rows in code Determining whether the current item is the last one from inside ItemDataBound Setup question Custom Datagridstyle Using 2003 Data Adapters in 2005 |
|||||||||||||||||||||||