views:

108

answers:

1

VB.NET 2.0 Framework

I developed a control that implements IExtenderProvider in order to attach to controls and display a form for translating of the text of that control. This works great on regular controls on the form but the IExtenderProvider is not attaching to controls on UserControls by default.

Is it possible to modify the UserControl or my IExtenderProvider control to enable it to attach to controls on a UserControl?

Thanks!

+2  A: 

If you own the source code to the IExtenderProvider or UserControl, just change the implemenation to 1) have the extender "dig" into the UserControl.Controls property or 2) have the UserControl expose properties that wrap the control properties that will be extended. [If an extender extends a TextBox control, you cannot make a UserControl look like a TextBox no matter what properties are exposed.]

AMissico
I was hoping to not have to do what you are suggesting in your first suggestion and get it to automatically traverse the UserControl control list and attach to the appropriate controls much like how it does a Panel or Groupbox (so I could toggle settings in the designer), but this doesn't seem possible. I implemented it by traversing the list and forcing it to attach with some default settings.
Justin
"how it does a Panel or Groupbox" These are just container controls. Any control placed in/on them still maintain their identity. A UserControl is not a container control. Controls used in a UserControl become the UserControl.
AMissico
You are better off exposing the properties you are extending through the UserControl. It is not the responsibility of the extender to determine which controls to extend. It is up to the user control to determine/expose which properties it will expose.
AMissico
True, a UserControl is not a container control, but if you set the designer to be a container, it can contain other controls.I am not able to "expose" the properties of the extender through the UserControl. I have added properties for the controls that I am extending on the UserControl, but they do not receive the extender properties in the property window.
Justin
I have to take my statements back. I was thinking about your problem, so I "dug" into the Object Browser. The UserControl inherits from a ContainerControl, which inherits from a ScrollableControl, which inherits from a Control. It seems all you can do is create an IExtenderProvider that "digs" into the UserControl Controls property.
AMissico
My statements regarding "exposing properties on the user control" are wrong. If you have an extender that extends a TextBox, you cannot make the UserControl look like a text box.
AMissico