Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Define Custom Strings for Properties in the Property Grid

Posted on 2008-06-24
2
Medium Priority
?
407 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 2000 total points
ID: 21856754
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

597 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