Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
130
Exception when trying to remove toolbar from ToolbarsManager
posted

Hi there,

Currently I am working on docking a toolbar from an MDI parent into the MDI child and vise versa. For some reason, I am unable to remove the toolbar from a toolbar manager.

Attached is my sample of the application. There is a toolbar manager in Form1 and Form2 where each of them should be able to be removed  from their respective toolbar manager. However by tearing the toolbar off from its manager and try to dock it into the other manager, I get a NullReferenceException from the code.

In my attached sample, I put two buttons where by clicking the Add button it will add a toolbar into the manager and the Remove button will remove the toolbar from the manager. I use the same method to remove the toolbar between tearing the toolbar and clicking on the buttons, but for some reason, they return a different result as I mention above.

What I am trying to achieve here is to be able to dock/undock the toolbar and switch them between managers. There is also another question on this matter. How do I detect if I am dragging the toolbar in the Form1 or Form2 area? At the moment, whenever I undock a toolbar, it will go straight to whether the MDI parent / child without checking on its active hovered area.

It would be great if some sample code is provided.

Many thanks for your help