Posted By: object88 | Oct 18th, 2004 @ 12:25 PM
page 1 of 1
Comments: 6 | Views: 9991
object88
object88
amplify.
I need some help with a .NET form designer.  I have a control (View) that I've written, and it has a object hanging off it (ViewOptions).  ViewOptions is essentially a bunch of simple properties (ints, strings, enums) with the occasional changed event.  For the control itself, I haven't changed the designer, but the ViewOptions shows up as a property, so I added a form to ease changes to it.

I can make changes in the ViewOptions form, close that form, and reopen it, and my changes are still there.  However, should I close the designer, all my changes go away... so how do I persist my changes to the ViewOptions object (via the form) into the user's code?

Are there any examples out on the web that I could check out?

Thanks!

Frank Hileman
Frank Hileman
VG.net
TypeDescriptor.GetProperties(component)["PropertyName"].SetValue(component, value);

That will:
a) create and close DesignerTransaction so you can participate in undo/redo

b) call OnComponentChanging/OnComponentChanged for you so the designers are informed
Frank Hileman
Frank Hileman
VG.net
Without the DesignerTransaction your change will not go into the undo/redo stack. This is very important for the end user, to make sense of what is happening on the screen.

OnComponentChanging/Changed does not by itself create a DesignerTransaction. You either have to create one yourself or use the SetValue method which wraps one around the change for you.
page 1 of 1