开发者

What is the correct method for a component editor to change properties on other controls?

开发者 https://www.devze.com 2022-12-16 22:38 出处:网络
I have a component that I am building an editor for. One of the things this component does is to allow other controls, of my own type, to be bound to this component.

I have a component that I am building an editor for. One of the things this component does is to allow other controls, of my own type, to be bound to this component.

The editor detects all such controls, and the editor will allow me to mass-edit this binding.

However, if the form file(s) is currently saved when I bring up the editor, changing th开发者_运维问答ose properties allows me to see the changes on those controls when I'm back in the normal form designer, but the file is still flagged as "unmodified", and thus no changes are saved.

What do I need to do in my component editor in order to tell the designer that something has happened?

Is it a simple flag or method call, or do I need a bigger tutorial on this?

Let me try to explain it better.

I drop a component on a form, it sits in the gray area beneath it, and on that component I have a property with its own property editor. This works.

When I invoke the property editor, it brings up a form, and in this form I list all other controls on the same form that the component was dropped on. This means that if I have a textbox and a combobox on that form, they show up in this dialog that was opened when I invoked the property editor. This also works.

If my property editor form changes any properties on that textbox or combobox, lets say it changes the .Text property, and then return back to my form by closing the property editor, I can inspect the textbox and combobox and see that the .Text property has indeed changed.

However, and this is the problem, the file is not flagged as modified. This means that if I hit F5, the debugger will start without a rebuild, and if I close and reopen the form, the properties are back to their last saved value.

I'll take a look at the OnComponentChange method from one of the answers and see if this fixes this problem.


As far as I can understand your question...

You should be able to handle designer notifications on property value changes with OnComponentChanging and OnComponentChange transactions. These methods are automatically called if SetValue was called:

TypeDescriptor.GetProperties(theComponent).Find(
    theName, True).SetValue(theComponent, theNewValue);

It is also possible to manually raise the OnComponentChange notification to tell the designer that something has happened and a change already occured.

0

精彩评论

暂无评论...
验证码 换一张
取 消