PropertyGrid dynamic Dropdown List

Tech-Archive recommends: Fix windows errors by optimizing your registry



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 [key/value] configuration settings in our application, so it seems to me that a PropertyGrid is a perfect modern replacement. I won't bore you with the details with all the controls on the dialog since I'm only concerned with one issue. The legacy dialog contains a drop down list control that is initialized with the same overall values but these values depend the context of an external object selected before the dialog is instantiated.
For example:
If the user selects widget FOO then the drop down list contains values such as COM1 and COM2.
However if the user selects widget BAR the drop down list contains values such as COM3 and COM4.
Further, if the user selects widget FOOBAR the drop down list contains values such as COM1, COM2, COM3 and COM4.
This is a common scenario in the dialog box, since there are 6 other drop down list controls
that behave similarly.
By the way, I'm writing this in C# in VSNet 2005 and the Property Grid control is the standard one available in the IDE. One minor addition, my supervisor has specified that the PropertyGrid control strategy should be used as the model for a number of other issues, so I'm committed to using the PropertyGrid control for the time being.

Here's how we've chosen to solve this issue in a PropertyGrid.
I'm attempting to use the same TypeConverter derived class on a property to initialize the drop down list control with these different values .
Below is a sample of the code:

public class myProp
{
string myStr;
[TypeConverter(typeof(MyConverter)]
public string MyItem
{
get { return myStr;}
set { myStr = value;}
}
}

public class MyConverter : StringConverter
{
}

Above, Property MyItem represents the TypeConverter object that will manage the values COM1,COM2, COM3, etc.

The problem is that instead of copying and pasting a ton of code, thereby creating many different classes and capturing multiple permutations, I want to implement one class, namely the myProp class to solve this issue elegantly.
However, since I can't pass any parameters to the MyItem property not can I pass any parameters to the MyConverter class, I'm at a dead end.
Does the nature of the PropertyGrid's declarative attributes also mean that data values are somewhat hard coded as well or is there a solution to my quandary? Should I shelve the PropertyGrid approach?
Any ideas or new strategies would be greatly appreciated.
Thanks
.



Relevant Pages

  • Re: Newbie question on the PropertyGrid Control
    ... The control can become very complex as soon as ... Home of Smart PropertyGrid for .Net and MFC ... Microsoft PropertyGrid Resource List - http://www.propertygridresourcelist.com ... A "TypeConverter" is only the beginning. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: PropertyGrid dynamic Dropdown List
    ... Home of Smart PropertyGrid for .Net and MFC ... If the user selects widget FOO then the drop down list contains values ... control is the standard one available in the IDE. ... Property MyItem represents the TypeConverter object that will ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: object properties presentation
    ... PropertyGrid, flipped DataGridView or maybe something else? ... The control should be able to inherently display property names and ... You can collect the data in a grid that's based on a collection of objects ... you have to customize the collection by implementing ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Showing different properties in design/run mode - user controls
    ... PropertyGrid ... communication class: user control ... base class ...
    (microsoft.public.dotnet.languages.csharp)
  • PropertyGrid Limitations ..Comments please
    ... In the PropertyGrid value cells, I am assigned to display the controls ... PropertyGrid It is however possible to draw the control in that area ... property grid (Displaying control in the complete cell area is not ...
    (microsoft.public.dotnet.languages.csharp)