Connecting Tech Pros Worldwide Forums | Help | Site Map

Propertygrid

Redivivus
Guest
 
Posts: n/a
#1: Oct 9 '07
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

=?Utf-8?B?SHVzYW0gQWwtQScnYXJhag==?=
Guest
 
Posts: n/a
#2: Oct 9 '07

re: Propertygrid


hi,
below is a useful link

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


cheers !

Husam Al-A'araj
www.aaraj.net

"Redivivus" wrote:
Quote:
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
>
Mex
Guest
 
Posts: n/a
#3: Oct 10 '07

re: Propertygrid


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" <meelis.lilbok@deltmar.eekirjutas sõnumis news:
OciQFKpCIHA.1168@TK2MSFTNGP02.phx.gbl...
Quote:
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
VisualHint
Guest
 
Posts: n/a
#4: Oct 12 '07

re: Propertygrid


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:
Quote:
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...
>
Quote:
Hi
>
Quote:
Ho to use dropdown inpropertygridwith values from database?
>
Quote:
Lets say i have table ITEMS
and columns ID, NAME
>
Quote:
Now i want to select id, name from items
and display those values in dropdown of mypropertygrid
>
Quote:
Best regards;
>
Quote:
Mex

Closed Thread