Xceed Docking Windows for WinForms v2.3 Documentation
Welcome to Xceed Docking Windows for WinForms v2.3 / Task-Based Help / How to create a custom border

In This Topic
    How to create a custom border
    In This Topic

    Each ToolWindow has a fixed 1-pixel border whose color can be changed via the BorderColor property. If the BorderColor property is set to Transparent or Empty then the tool window will not have its default 1-pixel border.

    In order to change the width of the border surrounding a tool window, the following steps are required:

    1. Add a panel to the tool-window and sets its Dock property to DockStyle.Fill.
    2. Set the tool-window's DockPadding property to the desired border width.
    3. Change the border color to the tool-window to Color.Empty.
    4. Change the background color of the tool window to the desired border color.
    5. Change the background color of the panel to the desired tool window color.

    The following example demonstrates how to create a tool window that has a 5-pixel light blue border.

    VB.NET
    Copy Code
    Imports System
    Imports System.Collections
    Imports System.ComponentModel
    Imports System.Drawing
    Imports System.Data
    Imports System.Windows.Forms 
    Namespace Xceed.DockingWindows.Samples
      Public Class ToolWindowBorder
        Inherits Xceed.DockingWindows.ToolWindow
        Private components As System.ComponentModel.Container = Nothing
        Public Sub New( key As String, text As String, borderColor As Color )
          InitializeComponent()
          Me.Key = key
          Me.Text = text
          Me.BackColor = borderColor
          Me.BorderColor = Color.Empty
          Me.DockPadding.All = 5
          Dim panel As New Panel()
          panel.BackColor = SystemColors.Control
          panel.Dock = DockStyle.Fill
          Me.Controls.Add( panel )
        End Sub
        Protected Overrides Overloads Sub Dispose( disposing As Boolean )
          If disposing Then
            If Not components Is Nothing Then
              components.Dispose()
            End If
          End If
          MyBase.Dispose( disposing )
        End Sub
        Private Sub InitializeComponent()
          Me.Name = "ToolWindowBorder"
          Me.Size = New System.Drawing.Size(296, 328)
        End Sub
      End Class
    End Namespace
    C#
    Copy Code

    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Drawing;
    using System.Data;
    using System.Windows.Forms;

    namespace Xceed.DockingWindows.Samples
    {
      public class ToolWindowBorder : Xceed.DockingWindows.ToolWindow
      {
        private System.ComponentModel.Container components = null;

        public ToolWindowBorder( string key, string text, Color borderColor )
        {
          InitializeComponent();

          this.Key = key;
          this.Text = text;
          this.BackColor = borderColor;
          this.BorderColor = Color.Empty;
          this.DockPadding.All = 5;

          Panel panel = new Panel();
          panel.BackColor = SystemColors.Control;
          panel.Dock = DockStyle.Fill;

          this.Controls.Add( panel );
        }

         protected override void Dispose( bool disposing )
         {
           if( disposing )
           {
             if(components != null)
             {
               components.Dispose();
             }
           }
           base.Dispose( disposing );
         }

         private void InitializeComponent()
         {
           this.Name = "ToolWindowBorder";
           this.Size = new System.Drawing.Size(296, 328);
         }
       }
    }