How to get ChildControl of ToolWindow

Docking/MDI for Windows Forms Forum

Posted 19 years ago by Boyd - Sr. Software Developer, Patterson Consulting, LLC
Avatar
When you create a ToolWindow programmatically, you pass the ChildControl that will be hosted inside the window. I need to enumerate all my ToolWindows and find the one containing a specific ChildControl. I looked at all the properties/methods of ToolWindow, and I didn't see how to retrieve a reference to the ChildControl. Can this be done?

Comments (5)

Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
You can optionally pass null into that parameter to the constructor. If you pass a Control in, it will dock-fill the control within the ToolWindow.

Since ToolWindow is a Control itself, you can look at and manipulate its Controls collection directly. So if you know you always only have one child control (UIStudio supports multiple child controls if you wish) in a tool window, then do this to get the child control:
Control childControl = toolWindow.Controls[0];


Actipro Software Support

Posted 19 years ago by Boyd - Sr. Software Developer, Patterson Consulting, LLC
Avatar
Thanks, I'll give that a shot. I also just found the 'ToolWindowFromControl' method, so I'm guessing that will help as well. Is there an equivalent method for DocumentWindows?
Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
We can add a DocumentWindowFromControl for the next release.

Or do you think we should rename the current method to TabbedMdiWindowFromControl? TabbedMdiWindow is the base class of both DocumentWindow and ToolWindow. What do you think would be better?


Actipro Software Support

Posted 19 years ago by Boyd - Sr. Software Developer, Patterson Consulting, LLC
Avatar
I like TabbedMdiWindowFromControl better. It's not possible to have the same control in both a DocumentWindow and a ToolWindow, so there's no real need to differentiate between the two collections. The developer can always test the type of the returned item to see if it's a DocumentWindow or ToolWindow.
Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
We'll rename the existing method and have it return a TabbedMdiWindow instead. That does make better sense.


Actipro Software Support

The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.