473,406 Members | 2,816 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,406 software developers and data experts.

Propertygrid

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 dropdown of my propertygrid
Best regards;

Mex
Oct 9 '07 #1
3 5169
hi,
below is a useful link

http://www.codeproject.com/csharp/dr...properties.asp
cheers !

Husam Al-A'araj
www.aaraj.net

"Redivivus" wrote:
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 dropdown of my propertygrid
Best regards;

Mex
Oct 9 '07 #2
Mex
Ok i know now hot to use simple combobox in propertygrid
(see code below)
but how to add items with value
Mother=1,Sister=2
and when user select item from combobox i get valuemember not displaymember?
Mex
public class FamilyMember : Component
{

private string relation = "Unknown";

[TypeConverter(typeof(RelationConverter)),Category( "Details")]
public string Relation
{
get { return relation; }
set { this.relation = value; }
}
}

internal class RelationConverter : StringConverter
{

private static StandardValuesCollection defaultRelations =
new StandardValuesCollection(
new string[]{"Mother", "Father", "Sister",
"Brother", "Daughter", "Son",
"Aunt", "Uncle", "Cousin"});
public override bool GetStandardValuesSupported(
ITypeDescriptorContext context)
{
return true;
}

public override bool GetStandardValuesExclusive(
ITypeDescriptorContext context)
{
// returning false here means the property will
// have a drop down and a value that can be manually
// entered.
return true;
}

public override StandardValuesCollection GetStandardValues(
ITypeDescriptorContext context)
{
return defaultRelations;
}
}

"Redivivus" <me***********@deltmar.eekirjutas sõnumis news:
Oc**************@TK2MSFTNGP02.phx.gbl...
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 dropdown of my propertygrid
Best regards;

Mex
Oct 10 '07 #3
Hello Mex,

instead of using strings in your standard values, use objects that
store an integer but whose TypeConverter returns the string you want
for the integer. This is what my previously mentioned article
explains.

Best regards,

Nicolas Cadilhac @ VisualHint (http://www.visualhint.com)
Home of Smart FieldPackEditor.Net / DateTimePicker replacement (http://
www.visualhint.com/index.php/fieldpackeditor)
Home of Smart PropertyGrid for .Net and MFC (http://www.visualhint.com/
index.php/propertygrid)
Microsoft PropertyGrid Resource List - http://www.propertygridresourcelist.com

On Oct 10, 8:47 am, "Mex" <redivi...@hot.eewrote:
Ok i know now hot to use simple combobox inpropertygrid
(see code below)
but how to add items with value
Mother=1,Sister=2
and when user select item from combobox i get valuemember not displaymember?

Mex

public class FamilyMember : Component
{

private string relation = "Unknown";

[TypeConverter(typeof(RelationConverter)),Category( "Details")]
public string Relation
{
get { return relation; }
set { this.relation = value; }
}
}

internal class RelationConverter : StringConverter
{

private static StandardValuesCollection defaultRelations =
new StandardValuesCollection(
new string[]{"Mother", "Father", "Sister",
"Brother", "Daughter", "Son",
"Aunt", "Uncle", "Cousin"});

public override bool GetStandardValuesSupported(
ITypeDescriptorContext context)
{
return true;
}

public override bool GetStandardValuesExclusive(
ITypeDescriptorContext context)
{
// returning false here means the property will
// have a drop down and a value that can be manually
// entered.
return true;
}

public override StandardValuesCollection GetStandardValues(
ITypeDescriptorContext context)
{
return defaultRelations;
}
}

"Redivivus" <meelis.lil...@deltmar.eekirjutas sõnumis news:
OciQFKpCIHA.1...@TK2MSFTNGP02.phx.gbl...
Hi
Ho to use dropdown inpropertygridwith 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 dropdown of mypropertygrid
Best regards;
Mex

Oct 12 '07 #4

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

Similar topics

6
by: Terry | last post by:
I have a very basic program, but for some reason I can't get it to behave properly. What I want is a basic form with a TabControl that fills the entire form. The tab control should have 4 tabs...
3
by: Dave Girvitz | last post by:
I have a PropertyGrid (Windows Forms App) based component that uses TypeConverters to generate ranges of acceptable values for properties. The idea was that I could download the key/value pairs...
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...
1
by: Lance | last post by:
Is there any way to tell a Windows.Forms.PropertyGrid to update the values for the properties that it is displaying? I am having trouble getting the PropertyGrid to update when I make changes to...
7
by: siddhiash | last post by:
Hi Friends I want to add PasswordChar Property which shows ****** for string which I type in PropertyGrid Control. Regards, Siddharth
4
by: Bernie Yaeger | last post by:
How can I set the browsableattributes of the control that has been selected (selectedobject) by the propertygrid? Here's what I'm after - I want to open a form with a propertygrid in it. The...
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
5
by: Sharon | last post by:
I'm using the PropertyGrid control, and I want it to show a button. But I set the PropertyGrid.SelectedObject with a object that as a Button property, the PropertyGrid shows the buttons properties,...
4
by: phcmi | last post by:
I have a PropertyGrid question. My task is to replace a legacy dialog box presentation with a modern one. The dialog itself allows the user to set configuration settings in our application, so...
3
by: =?Utf-8?B?U3RldmVU?= | last post by:
Is it possible to hide a row within a PropertyGrid based upon the boolean value of another row within the PropertyGrid? I am using VS2005 with .NET Frameworks 2.0. -- ----------- Thanks,...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.