Define Custom Strings for Properties in the Property Grid
Posted on 2008-06-24
I am building a .NET control using C# 2008, my control contains some composite properties that has predefined values that are, and those predefines values are set from enumeration that are already defined in my control.
The Properties window display the enum values for the property of that enum type. So if you declare the following
Public enum MyEnum
Value1 = 0,
Value2 = 1,
Value3 = 2
Then declare a property of that enum type
Public MyEnum MyProperty
The values of the enum (Value1, Value2, Value3) appear in a combo next to the property name in the Property Window
My problem is that I do not want the property to display the enum values. I want the property to display my own named value such as
0 Value 1
1 Value 2
2 Value 3
Instead of Value1, Value2, Value3
How can I make the property show such values in Visual Studio Property Window?
I know that in ActiveX controls we use IPerPropertyBrowser interface, but how to do it in .net C#?
I cant implement this interface because it deals with dispatch IDs ( a COM thing)
Thanks in Advance