ASD-JO
asked on
Define Custom Strings for Properties in the Property Grid
Hello Experts,
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
{
Get
{
}
Set
{
}
}
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
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
{
Get
{
}
Set
{
}
}
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
public class MyControl
{
...
public MyControl()
{
MyProperty = MyEnum.Value1;
}
...
}