# Sidebar and Panels

> Dock Windows Forms sidebars, connect them to ribbon buttons, show them as dialogs, hide panel elements with FindItem and show your own control as Content.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control .NET for Windows Forms > Document Editor > Ribbon and UI > Sidebar and Panels
- **4941 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/ribbon-ui/sidebar/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/ribbon-ui/sidebar/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/ribbon-ui/sidebar/llms-full.txt

---

How should a sidebar behave in your application: always docked beside the document, opened by a ribbon button, floating as a dialog, or showing a panel of your own? The `Sidebar` control of TX Text Control .NET for Windows Forms does all four. Its layout follows the docking, ribbon buttons open it with the right panel, single elements of a predefined panel can be hidden, and your code can react when the panel changes.

What a sidebar is and which panels it offers is described in [Sidebar](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/overview/components/sidebar/llms-full.txt), and [Create a Ribbon Application with Sidebar Support](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/getting-started/document-editor/ribbon-sidebar/llms-full.txt) adds one to a form step by step.

### Set Up a Sidebar in the Designer

The smart tag of a `TextControl` adds a bottom, a left or a right sidebar. The smart tag of the sidebar then sets its most used properties: the panel in **ContentLayout**, the **Dock** position, the connected **TextControl**, the title **Text**, and the check boxes **ShowTitle**, **ShowPinButton**, **ShowCloseButton**, **IsPinned** and **IsShown**.

![The Sidebar Tasks smart tag with the ContentLayout drop-down open, listing None, Custom, Goto, FieldNavigator, TrackedChanges, Styles, Find, Replace, ConditionalInstructions, DocumentSettings, Comments and About, next to a Styles sidebar in the designer.](https://docs.textcontrol.com/assets/img/tx-text-control-dotnet-winforms/sidebar-content-layout.0e176eb7.webp)

The TX Words sample shows its **About** panel in the left sidebar at startup and clears **ShowPinButton**, so that users cannot turn the sidebar into a dialog:

![The smart tag of the left sidebar of TX Words with ContentLayout About, Dock Left, TextControl m_txTextControl, and ShowPinButton cleared.](https://docs.textcontrol.com/assets/img/tx-text-control-dotnet-winforms/sidebar-smart-tag-about.ed517874.webp)

### Layout Follows the Docking

The panels **Find**, **Replace**, **Goto**, **ConditionalInstructions**, **DocumentSettings** and **FieldNavigator** have two layouts. The [ContentLayout](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms/sidebar/contentlayout-property/llms-full.txt) and the `Dock` property of the sidebar decide which one is shown:

| `Dock` | Layout |
|---|---|
| `Left` or `Right` | Vertical, for a sidebar beside the document |
| `Top` or `Bottom` | Horizontal, for a strip above or below the document |
| `Fill` or `None` | Dialog style |

This is why the ribbon tabs connect two sidebars to some buttons, a vertical one and a horizontal one.

### Open Sidebars With Ribbon Buttons

Most sidebar buttons of a ribbon tab have two connection properties, one for a vertical and one for a horizontal sidebar, for example [FindSidebar](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribbonformattingtab/findsidebar-property/llms-full.txt) and [FindHorizontalSidebar](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribbonformattingtab/findhorizontalsidebar-property/llms-full.txt) of the Home tab. These are the connection properties of all tabs:

| Tab | Properties | Button |
|---|---|---|
| [RibbonFormattingTab](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribbonformattingtab/llms-full.txt) | [FindSidebar](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribbonformattingtab/findsidebar-property/llms-full.txt), [FindHorizontalSidebar](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribbonformattingtab/findhorizontalsidebar-property/llms-full.txt) | Find |
|  | [ReplaceSidebar](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribbonformattingtab/replacesidebar-property/llms-full.txt), [ReplaceHorizontalSidebar](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribbonformattingtab/replacehorizontalsidebar-property/llms-full.txt) | Replace |
|  | [GotoSidebar](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribbonformattingtab/gotosidebar-property/llms-full.txt), [GotoHorizontalSidebar](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribbonformattingtab/gotohorizontalsidebar-property/llms-full.txt) | Go To |
|  | [StylesSidebar](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribbonformattingtab/stylessidebar-property/llms-full.txt) | The dialog box launcher of the Styles group |
| [RibbonProofingTab](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribbonproofingtab/llms-full.txt) | [TrackedChangesSidebar](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribbonproofingtab/trackedchangessidebar-property/llms-full.txt), [TrackedChangesHorizontalSidebar](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribbonproofingtab/trackedchangeshorizontalsidebar-property/llms-full.txt) | Tracked Changes |
|  | [CommentsSidebar](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribbonproofingtab/commentssidebar-property/llms-full.txt), [CommentsHorizontalSidebar](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribbonproofingtab/commentshorizontalsidebar-property/llms-full.txt) | Comments |
| [RibbonFormFieldsTab](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribbonformfieldstab/llms-full.txt) | [ConditionalInstructionsSidebar](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribbonformfieldstab/conditionalinstructionssidebar-property/llms-full.txt), [ConditionalInstructionsHorizontalSidebar](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribbonformfieldstab/conditionalinstructionshorizontalsidebar-property/llms-full.txt) | Manage Conditional Instructions |
| [RibbonReportingTab](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribbonreportingtab/llms-full.txt) | [FieldNavigatorSidebar](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribbonreportingtab/fieldnavigatorsidebar-property/llms-full.txt) | Field Navigation |

You set these properties in the **Properties** window of the tab, in the **Connected Sidebars** section of the tab's smart tag shown below, or in code. When a sidebar is connected, the button gets a drop-down with a toggle for each connected sidebar, and a click on the button works as follows:

- **Toggle on.** The connected sidebar opens pinned into the form.
- **Toggle off.** The sidebar opens as a dialog: one that cannot be resized for the Find, Replace and Go To buttons, a resizable one for the Comments, Tracked Changes and Conditional Instructions buttons.
- **In both cases** the sidebar switches to the panel of the button, and the other connected sidebar of the same button is hidden.

The **Styles** dialog box launcher and the **Field Navigation** button are the exceptions: [StylesSidebar](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribbonformattingtab/stylessidebar-property/llms-full.txt) and `FieldNavigatorSidebar` connect one sidebar only. The **Connected Sidebars** section of the smart tag of a predefined tab sets the properties in the designer:

![The RibbonFormattingTab Tasks smart tag with its Connected Sidebars section: the Find, Go To and Replace buttons each have a horizontal and a vertical sidebar, and the Styles dialog box launcher one sidebar.](https://docs.textcontrol.com/assets/img/tx-text-control-dotnet-winforms/connected-sidebars.aaebf93b.webp)

One sidebar can serve several buttons, because each button sets the panel it needs. TX Words connects the vertical properties, except `GotoSidebar`, to a right sidebar and the horizontal properties to a bottom sidebar.

The following code, in the constructor of the form after `InitializeComponent`, connects a sidebar docked at the right to three buttons and hides it until one of them is clicked:

```csharp
// Connect the sidebar to the editor and to three ribbon buttons
sidebarRight.TextControl = textControl1;
ribbonFormattingTab1.StylesSidebar = sidebarRight;
ribbonProofingTab1.TrackedChangesSidebar = sidebarRight;
ribbonProofingTab1.CommentsSidebar = sidebarRight;

// Show the sidebar only when a button opens it
sidebarRight.IsShown = false;
```

### Show a Sidebar as a Dialog

A sidebar is either pinned into the form, when [IsPinned](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms/sidebar/ispinned-property/llms-full.txt) is `true`, the default, or opens as a dialog when it is `false`. Users switch between the two with the pin button in its title bar. The following code, in the constructor of the form after `InitializeComponent`, opens the **Find** panel in a resizable dialog of a fixed size:

```csharp
using TXTextControl.Windows.Forms;

// Show the Find panel in a sizable dialog
sidebarRight.TextControl = textControl1;
sidebarRight.ContentLayout = Sidebar.SidebarContentLayout.Find;
sidebarRight.IsPinned = false;
sidebarRight.DialogStyle = Sidebar.SidebarDialogStyle.StandardSizable;
sidebarRight.DialogSize = new Size(320, 480);
sidebarRight.IsShown = true;
```

The code works as follows:

- [DialogStyle](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms/sidebar/dialogstyle-property/llms-full.txt) takes a [SidebarDialogStyle](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms/sidebar/sidebardialogstyle-enumeration/llms-full.txt): `Standard`, the default, is a fixed dialog with a title bar; `StandardSizable` can be resized; `Sidebar` and `SidebarSizable` show the sidebar without the border and title bar of a dialog.
- [DialogSize](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms/sidebar/dialogsize-property/llms-full.txt) and [DialogLocation](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms/sidebar/dialoglocation-property/llms-full.txt) set size and position. Left at their defaults, `Size.Empty` and `Point.Empty`, the dialog is sized to its content and centered on the topmost control.
- [IsShown](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms/sidebar/isshown-property/llms-full.txt) shows the sidebar. Use it rather than the inherited `Visible` property, which the sidebar uses internally.

A pinned sidebar can be resized with the mouse while [IsSizable](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms/sidebar/issizable-property/llms-full.txt) is `true`, its default, provided `AutoSize` is `false` and `Dock` is not `Fill`.

### Hide Elements of a Panel

Every element of a predefined panel has an identifier, and [FindItem](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms/sidebar/finditem-method/llms-full.txt) returns it as a Windows Forms control. There is one enumeration per panel, nested in `Sidebar`:

| Enumeration | Panel | Examples |
|---|---|---|
| [FindAndReplaceItem](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms/sidebar/findandreplaceitem-enumeration/llms-full.txt) | Find, Replace | `TXITEM_MatchCase`, `TXITEM_SearchUp`, `TXITEM_SearchInFootnotes`, `TXITEM_ReplaceAll` |
| [StylesItem](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms/sidebar/stylesitem-enumeration/llms-full.txt) | Styles | `TXITEM_ShowPreview`, `TXITEM_SortAlphabetical`, `TXITEM_ManageStyles` |
| [GotoItem](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms/sidebar/gotoitem-enumeration/llms-full.txt) | Goto | `TXITEM_GotoList`, `TXITEM_GotoNext` |
| [TrackedChangesItem](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms/sidebar/trackedchangesitem-enumeration/llms-full.txt) | TrackedChanges | `TXITEM_TrackedChangesCount`, `TXITEM_TrackedChangesRefresh` |
| [ConditionalInstructionsItem](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms/sidebar/conditionalinstructionsitem-enumeration/llms-full.txt) | ConditionalInstructions | `TXITEM_New`, `TXITEM_Edit`, `TXITEM_Delete` |
| [DocumentSettingsItem](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms/sidebar/documentsettingsitem-enumeration/llms-full.txt) | DocumentSettings | `TXITEM_CustomPropertiesPanel`, `TXITEM_EmbeddedFilesPanel` |
| [FieldNavigatorItem](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms/sidebar/fieldnavigatoritem-enumeration/llms-full.txt) | FieldNavigator | `TXITEM_SearchTextBox`, `TXITEM_MergeFieldDelete` |

The following code hides the **Search up** option of the find panel:

```csharp
// Hide an element of the predefined Find panel
Control searchUp = sidebarRight.FindItem(Sidebar.FindAndReplaceItem.TXITEM_SearchUp);
if (searchUp != null)
{
    searchUp.Visible = false;
}
```

### React to Changes of the Panel

`Sidebar` implements `System.ComponentModel.INotifyPropertyChanged`, so its `PropertyChanged` event tells you when a ribbon button or the user changed `ContentLayout` or `IsShown`. TX Words uses it for its left sidebar, which shows three panels: tracked changes, opened by the Proofing tab, and the document settings and About panels, opened by two toggle buttons of its application menu. The handler allows a dialog only for the tracked changes panel and keeps the two toggle buttons checked while their panel is visible:

```csharp
using System.ComponentModel;
using TXTextControl.Windows.Forms;

// In the constructor, after InitializeComponent
sidebarLeft.PropertyChanged += SidebarLeft_PropertyChanged;

private void SidebarLeft_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
    switch (e.PropertyName)
    {
        case "ContentLayout":
            switch (sidebarLeft.ContentLayout)
            {
                case Sidebar.SidebarContentLayout.TrackedChanges:
                    // The user may turn this panel into a dialog
                    sidebarLeft.ShowPinButton = true;
                    documentSettingsButton.Checked = false;
                    aboutButton.Checked = false;
                    break;
                case Sidebar.SidebarContentLayout.DocumentSettings:
                    // Always docked, no pin button
                    sidebarLeft.ShowPinButton = false;
                    sidebarLeft.IsPinned = true;
                    documentSettingsButton.Checked = true;
                    aboutButton.Checked = false;
                    break;
                case Sidebar.SidebarContentLayout.About:
                    sidebarLeft.ShowPinButton = false;
                    sidebarLeft.IsPinned = true;
                    documentSettingsButton.Checked = false;
                    aboutButton.Checked = true;
                    break;
            }
            break;

        case "IsShown":
            // A button is checked only while its panel is visible
            documentSettingsButton.Checked = sidebarLeft.IsShown
                && sidebarLeft.ContentLayout == Sidebar.SidebarContentLayout.DocumentSettings;
            aboutButton.Checked = sidebarLeft.IsShown
                && sidebarLeft.ContentLayout == Sidebar.SidebarContentLayout.About;
            break;
    }
}
```

The code works as follows:

- `e.PropertyName` names the property that changed, as a string: `"ContentLayout"` when another panel is shown, `"IsShown"` when the sidebar is opened or closed.
- `documentSettingsButton` and `aboutButton` are [RibbonToggleButton](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribbontogglebutton/llms-full.txt) controls whose click handlers set `ContentLayout` and `IsShown` of the sidebar. [Checked](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms-ribbon/ribbontogglebutton/checked-property/llms-full.txt) shows them pressed.
- Setting `IsPinned` to `true` together with hiding the pin button docks a panel that was open as a dialog back into the form, and users cannot undock it again.

[ShowPinButton](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms/sidebar/showpinbutton-property/llms-full.txt), [ShowCloseButton](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms/sidebar/showclosebutton-property/llms-full.txt) and [ShowTitle](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms/sidebar/showtitle-property/llms-full.txt) switch the parts of the title bar. [TitleFont](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms/sidebar/titlefont-property/llms-full.txt), by default Calibri Light at 18 points, and [TitleForeColor](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms/sidebar/titleforecolor-property/llms-full.txt) set the look of the title.

### Show a Panel of Your Own

With `ContentLayout` set to `Custom`, the sidebar shows any Windows Forms control assigned to its [Content](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-windows-forms/sidebar/content-property/llms-full.txt) property, with the same title bar, docking and dialog mode as a predefined panel. `Content` can be set only with this layout. The following code shows a user control of your application, here named `CustomerPanel`, in a sidebar:

```csharp
using TXTextControl.Windows.Forms;

// Show a control of your own in the sidebar
sidebarLeft.ContentLayout = Sidebar.SidebarContentLayout.Custom;
sidebarLeft.Content = new CustomerPanel();
sidebarLeft.Text = "Customer";
sidebarLeft.ShowPinButton = false;
```

### Next Steps

- [Track Changes](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/track-changes/llms-full.txt) and [Comments](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/comments/llms-full.txt): the features behind two of the panels.
- [Form Fields and Conditional Instructions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/form-fields/llms-full.txt): the conditional instructions panel.
- [Built-in Ribbon Tabs](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/ribbon-ui/ribbon/llms-full.txt): the tabs whose buttons open the sidebars.
- The blog article [Getting Started: Creating a .NET 8 Windows Forms Ribbon Application with Sidebar Support](https://www.textcontrol.com/blog/2024/02/28/getting-started-creating-a-net-8-windows-forms-ribbon-application-with-sidebar-support/): a ribbon application with sidebars, with screenshots.

---

## Nearby

- **Previous:** [Rulers and Status Bar](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/ribbon-ui/rulers-status-bar/llms-full.txt)
- **Next:** [Context Menus](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/ribbon-ui/context-menus/llms-full.txt)
