How to prevent ToolStrip from docking in another ToolStripContainer?
I have an MDI application that allows me to open different types of child windows. I can open multiple (but different) instances of the same type of child window. (Example: I can open 3 instances of child window type A and 2 instances of child window type B. All 5 windows are distinct entities and do not share data until unless the user explicitly drags the same data onto multiple windows.) Each child window has a ToolStripContainer with one or more ToolStrips. How do I prevent:
I'm trying to prevent the user from dragging a ToolStrip from instance 1 of type A to instance 2 of type A, selecting some stuff on instance 2, and then clicking a button on the toolbar only to have something weird happen to some other window. Similarly it doesn't make sense to drag a ToolStrip from a window of type A to a window of type B -- the actions don't apply to that type, but to the user it looks like everything is fine because I let them do the drag. Is it as simple as adding my own handler for the ControlAdded event or is there a better way to do this? I'm using WinForms in .NET 3.0. edit: Steps to reproduce
|
||||
|
This feels like a hack, but it works (kind of) (sorry, vb.net not c#):
simply put; when the control is finished being dragged, if its parent ToolStripContainer is not the same as it was when it started dragging, move the toolstrip back to where it was. im sure this could be rolled into a control so that you dont have to write it for every toolbar. Edit: You could put all this code into a control that inherits from ToolStripContainer, and have it do all the work for you, meaning a nice encapsulated solution. |