Solved

Define Custom Strings for Properties in the Property Grid

Posted on 2008-06-24
2
402 Views
Last Modified: 2013-12-16
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
0
Comment
Question by:ASD-JO
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 18

Expert Comment

by:philipjonathan
ID: 21856326
Would it help if you initialise the default value in the control's constructor:

public class MyControl
{
...
  public MyControl()
  {
    MyProperty = MyEnum.Value1;
  }
...
}
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 21856754
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question