473,385 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Combobox in propertygrid?

How do I use a combobox in a propertygrid without using enum ?
Any suggestions?
Nov 15 '05 #1
1 24597
You need to implement a type converter for your property.
http://msdn.microsoft.com/library/de...classtopic.asp
For example, if you have a string property that you want to limit to a few
choices, create a class like this:
public class MyConverter : StringConverter
{
public override bool GetStandardValuesSupported(ITypeDescriptorContext
context)
{
//true means show a combobox
return true;
}
public override bool GetStandardValuesExclusive(ITypeDescriptorContext
context)
{
//true will limit to list. false will show the list, but allow free-form
entry
return true;
}

public override
System.ComponentModel.TypeConverter.StandardValues Collection
GetStandardValues(ITypeDescriptorContext context)
{
return new StandardValuesCollection(
new string[] { "entry1", "entry2", "entry3" });
}

}
Then hook it up to your property like this: (note the [TypeConverter]
attribute)
private string _myProp = "entry1";
[Browsable(true)]
[DefaultValue("entry1")]
[CategoryAttribute("Behavior")]
[TypeConverter(typeof(MyConverter))]
public string MyProp
{
get{ return _myprop;}
set{ _myprop = value;}
}

"Daniel" <bb@aa.com> wrote in message
news:OA**************@tk2msftngp13.phx.gbl...
How do I use a combobox in a propertygrid without using enum ?
Any suggestions?

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: lobrys | last post by:
hi here is my question I use a propertyGrid to display/modify values some of my properties are in database...for exemple : a list of city (city_id, city_text) is it possible to give a...
2
by: Mevar81 | last post by:
Hi to everybody.I have a problem with the PropertyGrid control.I want to display not all the properties of a generic Control(Button,TextBox,ComboBox,ecc.).In general I don't want to display only...
1
by: newbie | last post by:
Hello, I am using a propertygrid to allow users to edit\create objects at runtime, that can update records in a database. There are certain properties (fields) that I wish to display as...
1
by: SDK | last post by:
I'm using a propertygrid control in my program, but I'm having some troubles implementing the following. I've got two classes, the second class has a property "Parent" which is an object of the...
1
by: ANDRES BECERRA | last post by:
Herfried K. Wagner was kind enough to point me to the PropertyGrid control http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwindowsformspropertygridclasstopic.asp I have found a few...
0
by: Marco Segurini | last post by:
HI, my form contains a combobox and a propertygrid control. At each string of the combobox is associated an object. When I select a string of the combobox the associated object is selected in...
6
by: Steve Teeples | last post by:
Can someone show me an example of how to place a "CheckedListBox" property within a PropertyGrid? -- ----------- Thanks, Steve
3
by: Redivivus | last post by:
Hi Ho to use dropdown in propertygrid with values from database? Lets say i have table ITEMS and columns ID, NAME Now i want to select id, name from items and display those values in...
1
by: asharda | last post by:
I am writing a WPF application and am using the windows propertygrid. I need to show a list or combobox of list of values the user can select for a particular property, but I do not know the values...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.