Derived class of StringCOnverter for dynamic propertygrid

M

moni

Hi,

I am trying to use, public class FileNameConverter : StringConverter
for creating a dropdown list within my dynamic property grid. Thus I
have the methods GetStandardValuesSupported, GetStandardValues, and
GetStandardValuesExclusive.

My problem is , that my GetStandardValues, needs to get values from a
database, whose name I need to pass from another class, how do I go
about doing that??

I would also need to pass 2 other parameters. And I am never calling
the class by its constructor.
The only time the class name gets passed is like this:

myProp = new PropertySpec(attribute, typeof(string), category,
description, valueofattribute,
typeof(System.Drawing.Design.UITypeEditor),
typeof(FileNameConverter));

where PropertySpec is my dynamic propertygrid class.

Please help.

Thanks alot!
 
M

Marc Gravell

At /best/, you have a context (ITypeDescriptorContext) instance
available to you. This gives you access to the containing instance
(Component) and property. For complex scenarios, the trick is to make
your converter be able to read any values it needs from the containing
instance. You can cast to this - if it isn't provided, or isn't
something you expect, then fail safe.

As a side node, I would have thought the popup approach might have
worked better for this type of thing...

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top