PropertyGrid and Static Objects?

  • Thread starter Thread starter Matthias Steinbart
  • Start date Start date
M

Matthias Steinbart

Hi,

I'm having a class which cannot be instanciated but is used throughout the
application to indicate the state of various options through it's static
properties. Now I was trying to hook this class up to a property-grid, so
that the states could be monitored. Unfortunately, the PropertyGrid expects
an instance of something for the SelectedObject property. Is there a way you
can put there an object with only static properties?

Thanks in advance!

Matthias
 
Well that sort of depends. If you are passing a class to the property grid
you can add a dummy value to it. The dummy value can look at anything you
want. Currently I pull data from a SQL server and display it in a drop down
list in the property grid.

You could also create a class that you pass to the property grid that
encloses the class you really want to pass. The first class would always
contain access to you static value and you orginal class would not have to
change.

You might also be able to override the DisplayName in a custom property
descriptor but I have never tried. To date my use of the property
descriptor has been with making friendly names for the display properties
that already exist.

Regards,
John
 
Back
Top