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