Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / October 2007

Tip: Looking for answers? Try searching our database.

Propertygrid

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Redivivus - 09 Oct 2007 17:37 GMT
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
Husam Al-A''araj - 09 Oct 2007 19:15 GMT
hi,
below is a useful link

http://www.codeproject.com/csharp/dropdownproperties.asp

cheers !

Husam Al-A'araj
www.aaraj.net

> Hi
>
[quoted text clipped - 9 lines]
>
> Mex
VisualHint - 10 Oct 2007 01:46 GMT
The mentioned article is a good start, however, instead of relying on
a global variable to hold the possible values for the dropdown box, I
would use the Instance property passed through the
ITypeDescriptorContext. The term "context" really means that you can
get your values from the current context, i.e. the currently selected
target instance of the PropertyGrid. I wrote an article not so long
ago which can give you some clues too (http://www.visualhint.com/
index.php/blog/post/
how_to_setup_a_truly_dynamic_combobox_in_the_propertygrid/)

Best regards,

Nicolas Cadilhac @ VisualHint
[url="http://www.visualhint.com/?
utm_source=msdn&utm_medium=signature&utm_campaign=spgnet"
title="Custom PropertyGrid for .Net"]Smart PropertyGrid.Net[/url]
[url="http://www.propertygridresourcelist.com" title="Free resources
for the Microsoft PropertyGrid"]Microsoft PropertyGrid Resource List[/
url]
Free [url="http://www.visualhint.com/index.php/propertygrid_mfc/?
utm_source=msdn&utm_medium=signature&utm_campaign=spgmfc" title="Free
MFC PropertyGrid"]PropertyGrid for MFC[/url]
[url="http://www.visualhint.com/index.php/fieldpackeditor/?
utm_source=msdn&utm_medium=signature&utm_campaign=sfpe" title="Custom
DateTimePicker"]Smart FieldPackEditor.Net / DateTimePicker[/url]

On Oct 9, 2:15 pm, Husam Al-A''araj
<HusamAlAa...@discussions.microsoft.com> wrote:
> hi,
> below is a useful link
[quoted text clipped - 18 lines]
>
> > Mex
VisualHint - 10 Oct 2007 01:49 GMT
Hello Mex,

The mentioned article is a good start, however, instead of relying on
a global variable to hold the possible values for the dropdown box, I
would use the Instance property passed through the
ITypeDescriptorContext. The term "context" really means that you can
get your values from the current context, i.e. the currently selected
target instance of the PropertyGrid. I wrote an article not so long
ago which can give you some clues too (http://www.visualhint.com/
index.php/blog/post/
how_to_setup_a_truly_dynamic_combobox_in_the_propertygrid/)

(sorry for the repost, the signature was awful)

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

> The mentioned article is a good start, however, instead of relying on
> a global variable to hold the possible values for the dropdown box, I
[quoted text clipped - 47 lines]
>
> > > Mex
Mex - 10 Oct 2007 13:47 GMT
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;
       }
   }

> Hi
>
[quoted text clipped - 9 lines]
>
> Mex
VisualHint - 12 Oct 2007 15:37 GMT
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

> Ok i know now hot to use simple combobox inpropertygrid
> (see code below)
[quoted text clipped - 64 lines]
>
> > Mex

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.