Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to prevent ToolStrip from docking in another ToolStripContainer?
    primarykey
    data
    text
    <p>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:</p> <ol> <li>the user from dragging a ToolStrip from a child window of type A to a ToolStripContainer in a child window of type B?</li> <li>the user from dragging a ToolStrip from one instance of child window A to a ToolStripContainer in another instances of the same type of window?</li> </ol> <p>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.</p> <p>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.</p> <p>edit: Steps to reproduce</p> <ol> <li>Create a new Windows Application project.</li> <li>Add a new user control. Give the control a ToolStripContainer that contains one ToolStrip with a single button.</li> <li>Repeat step 2, giving you a UserControl2 class.</li> <li>Compile the solution so UserControl1 and UserControl2 show up in your toolbox.</li> <li>Drag UserControl1 and UserControl2 onto the form. Set the borders so you know where the boundaries are.</li> <li>Run the app.</li> <li>It's now possible to drag the ToolStrip from the container in UserControl1 and drop it into the container in UserControl2 (leaving zero ToolStrips in UC1 and two ToolStrips in UC2.)</li> <li>Now imagine you only have access to the code in UserControl1. How do you prevent the user from dragging the ToolStrip out of that instance of the ToolStripContainer?</li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload