Create ToolWindow and DocumentWindow using Dock Control in C#
The following are the key properties of ToolWindow and DocumentWindow. They both implement the same interfaces and have the same set of properties. However, their behaviors are different at runtime.
- DockLocation , the property is used to determine the location of the DockWindow in the docking area. Its valid value includes Left, Right, Top, Bottom, Fill, or Default.
- AllowedDockState , the property is used to determine the available dock states for a DockWindow.
- DockState , the property is used to determine the current state of the DockWindow. Its valid value includes Docked, Floating, AutoHide, Hidden, TabbedDocument.
- DockType , this is a read only property and includes one of the Tettic.WinFormsControls.Dock.Type enumeration members ToolWindow for ToolWindow or Document for DocumentWindow.
- Name , this is a property used to identify each dock panel or tabbed document and will be used while saving and restoring content.
- Image , this is a property used to assign an image that will be displayed in the tab for the ToolWindow or DocumentWindow.
- Text , this is a property used to determine the text that will be displayed in the caption bar at the top of the ToolWindow and the text that will be displayed on the tab at the bottom of the ToolWindow.
Methods of ToolWindow and DocumentWindow
- Close(), this method is used to close a ToolWindow or a DocumentWindow. Developers can use this method to hide or dispose the ToolWindow and DocumentWindow depending on the default behavior and the property of CloseAction.
- Display(), this method is used to display a hidden ToolWindow or DocumentWindow.
- DockTo(), this method is able to dock a window with another window in the same container. The C# code snippet shows how to dock Bottom Window to the container of Top Window.
Create ToolWindow and DocumentWindow at Runtime
How to Create ToolWindow at Runtime
If developers need to create a new ToolWindow, they need to create a ToolWindow instance, configure the properties, and call the Dock Control DockWindow() method, which passes a reference to the ToolWindow, and a DockLocation value.
ToolWindow windowTop = new ToolWindow();
windowTop.Text = "Top Window";
How to Create DocumentWindow at Runtime
If developers need to create a new DocumentWindow, they need to create an DocumentWindow instance, configure the properties, and call the Dock Control AddDocument() method, which passes the DocumentWindow instance.
DocumentWindow documentTop = new DocumentWindow();
documentTop.Text = "A New Document";