473,386 Members | 1,779 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,386 software developers and data experts.

populate a listbox/combox in a propertygrid at run-tim

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 at
compile time and hence cannot use Enum's. I looked up the net but
couldn't find a good example or code that I can use. If anyone has
done this and can share the code with me it will be very helpful. The
combo or list gets populated as the user adds objects to the screen.

Thanks for your time in advance.
Jun 27 '08 #1
1 4236
On May 28, 9:45 am, asha...@woh.rr.com wrote:
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 at
compile time and hence cannot use Enum's. I looked up the net but
couldn't find a good example or code that I can use. If anyone has
done this and can share the code with me it will be very helpful. The
combo or list gets populated as the user adds objects to the screen.

Thanks for your time in advance.
I figured out how to it so thought of posting it here.

Add this above the property you want displayed in the propertygrid
[TypeConverter(typeof(ListTypeConverter))]
Add this code in your main code
ListTypeConverter.SetList(lst); where lst is a generic list of items.
everytime u add an element to lst call the SetList method.
Add this class to your project
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
namespace YourSpace
{
public class ListTypeConverter : TypeConverter
{
private static List m_list = new List();
public override bool GetStandardValuesSupported(ITypeDescriptorContext
context)
{
return true;
}

public override bool GetStandardValuesExclusive(ITypeDescriptorContext
context)
{
return true;
}
private StandardValuesCollection GetValues()
{
return new StandardValuesCollection(m_list);
}
public static void SetList(List list)
{
m_list = list;
}

public override StandardValuesCollection
GetStandardValues(ITypeDescriptorContext context)
{
return GetValues();
}
}
}
Jun 27 '08 #2

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

Similar topics

4
by: Charles A. Lackman | last post by:
Hello, I have a combox that I am trying to get to work in the following fashion. As you type in the combox that the item that matches what you are type is selected. as you type a last name:...
2
by: Wishing I was skiing mom | last post by:
Newbie to VB .NET. My solution contains an item maintenance screen, one of the fields on the screen is an item status, this field is defined as a listbox. The listbox item property contains a...
2
by: Alpha | last post by:
How do I change the selected item in a listbox according to a Combox's selected item on the same form? The Combox is from a different table in the same dataset as the Listbox uses. Combox's...
2
by: Alpha | last post by:
I have a window application. On one of the form, there is a listbox and a few combox. The lstSchItem has a dataview as a datasource. The comboxes are bind to its selected value but through the...
1
by: Devin Wood | last post by:
Hi, I have a page with a ListBox on it, and It's also have a some buttons to populate the ListBox by using JavaScript. I have no problem with populate the listbox using JavaScript. But when 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: David J | last post by:
Hi, I am strugling with the propertygrid and a listbox. I am using the universaldropdowneditor from the codeproject (code below). However I am populating the listbox via a datasource. The problem...
16
by: agrawal.solutions | last post by:
Hello Friends I am asking a very silly question but i dont find any solution fo this.. I am selectiong a recordset and want to populate a combobox where id would be inviseble and the content...
14
by: rdade22 | last post by:
I have a combo box (cboStore) and a listbox (Qlist) both are unbound to a form call frmFAQ. What I want is to be a able to select a Subject from the combo box and have the results show up in the...
1
by: Steve Richter | last post by:
I have a form. In the Form is a MenuStrip and a FlowLayoutPanel. In the FlowLayoutPanel is a ListBox. The FlowLayoutPanel is set to DockStyle.Fill. The ListBox is set to AnchorStyles.Left |...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.