Archive for January, 2008

Visual Studio Tip: Document Outline window

Sunday, January 13th, 2008

Screenshot showing Document Outline window within Visual Studio 2005While developing System.Windows.Forms based applications it is common to end up with controls which are deeply nested within other controls (such as panels), or that are hard to select with the mouse (hidden behind another control). The Document Outline window is one solution to this problem.

Accessing the Document Outline Window
To enable the Document Outline Window select Document Outline within the Other Windows submenu of the main View menu (this feature also has the keyboard shortcut Ctrl + W, U).

Uses of the Document Outline Window
The Document Outline window provides a treeview showing the hierarchy of controls within the current form. By selecting a control within the Document Outline window you also select it within the Forms Designer and Properties window. By dragging and dropping within the Document Outline Window you can reparent and re-order controls within the form.

The feature I most use this window for is to re-order controls which I have docked to the same side of a panel. If you dock two or more controls to the top of a panel for example it is not as simple to use the mouse within the Form Designer to change which control is positioned at the top. Using the Document Outline window allows you to click and drag the controls to re-order them within the panel, and hence change the way the Docking and Anchoring layout algorithm is applied to them.

Another reason I use this feature is that it can be helpful since it does not loose all the event handlers you have hooked up to the controls which can occur if you cut and paste controls for example.