Runtime PropertyGrid and custom UITypeEditor with Business object

J

jc

I have a conundrum I'm hoping someone here might have an idea for:

I am implementing a propertygrid on a form that is "bound" to a business
object class containing global settings that a user will edit using the
property grid.
So far so good, works just fine etc etc.

One of the properties is a string that requires a separate dialog box to
edit it.

No problem normally: I can just use a custom UI Type editor, however, I
don't think I can because the class with the property being edited is in a
business object layer assembly that knows nothing about Windows Forms, it's
got no UI code whatsoever and is used for both the web and winform version
of the app.

I can't put the UIEditor code in the business object layer as that would
create a dependancy on windows forms.

I can't put the UIEditor code in the Winform UI layer assembly because I
would then need to reference it in the Editor attribute of the property in
the business object which would create a dependancy on the UI Layer which I
can't have obviously.

My only potential solution I can think of is to duplicate the business
objects properties in a "middle-man" object in the UI and copy back and
forth as it's edited, but this seems really clunky and will result in two
separate classes that need to be kept in sync during development rather than
the nice neat single one now.

I can't find any way of setting the editor at runtime and attributes can't
be changed at runtime so that avenue seems to be out as well.

Is there any way to accomplish this?

Any ideas would be gratefully appreciated.
 
N

noreply

Dear John,

I'm sorry that I have no real solution for your problem. The middleman
object is feasible but as you say this is not very elegant.

However this is the kind of thing that will be completey possible with
Smart PropertyGrid (http://www.propertygrid.net). The package
containing your business object won't be touched. It could be done like
this in the GUI package:

PropertyEnumerator propEnum = AddPropertyUnderCategory(parentEnum,
OBJ_ID, "Property label", this, "MyProperty", "A comment");
propEnum.Property.Feel = GetRegisteredFeel(PropertyGrid.FeelButton);
propEnum.Property.Value.Look = new MyPropertyLook();

A lots of other customizations could be added but what you describe is
a bit vague, so it's a bit difficult to show you what other benefits
SPG.NET could bring you.

Of course, instead of popping a dialog box to edit the object,
depending of what to edit, sub-properties could be created under the
business object property.

If you have any question, you can contact me directly from the
http://www.visualhint.com or http://www.propertygrid.net web sites.

Best regards

Nicolas Cadilhac
VisualHint
 

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