$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
CommandBar Control for C# Windows Forms
Easily customize the flexible CommandBar Control in WinForms C# projects at design time
Home > WinForms UI Controls > User Manual > Floating Strips in C#

CommandBar Floating Strips for WinForms C# Tutorial

The WinForms CommandBar control is a powerful and easy to use user interface control for Windows Forms. This CommandBar control provides large flexibility for developers to customize it. By using the WinForms CommandBar control, developers can rearrange strip elements on different rows elements. By using the CommandBar control, developers can dock the command bar strip element object to the commandbar or float the bar strip element object above the form. Additionally, it supports dragging a CommandBarStripElement from the CommandBar control and hosts and docks it to another.

Basics of the Bar Strip Element

When using the CommandBar Control, developers can use the two properties of EnableDragging and EnableFloating to float the CommandBarStripElement object. The value of the EnableDragging and EnableFloating properties should be set to true at the same time when need to float the CommandBarStripElement. If only one of the two properties be true, the command bar strip element can’t be floated. It is possible for users to drag the command bar strip element outside of its control to make it floating and dock it again by moving it over any command bar control.

Events of the Bar Strip Element

The following are some events which offer developers within the Command Bar Control over the floating and docking process.
FloatingStripCreate, this event will be fired if floating a command bar strip. Developers can use the C# code snippet below to prevent the bar strip OptionsStrip from being floating.

void commandBar1_FloatingStripCreating(object sender, CancelEventArgs e)
{
if ((sender as CommandBarStripElement).Name == "OptionsStrip")
{
e.Cancel = true;
}
}

FloatingStripCreated, this event will be fired if displaying the form that has been floated. Developers can use the C# Code snippet to set the caption text displayed on the floating form

void commandBar1_FloatingStripCreated(object sender, EventArgs e)
{
(sender as CommandBarStripElement).FloatingForm.Text = "Just a floating form";
}
FloatingStripDocking, this event will be fired if docking a floating strip to the CommandBar control. Developers can use the C# Code snippet to prevent the command bar strip, OptionsStrip, from being docked.

void commandBar1_FloatingStripDocking(object sender, CancelEventArgs e)
{
if ((sender as CommandBarStripElement).Name == "OptionsStrip")
{
e.Cancel = true;
}
}
FloatingStripDocked, this event will be fired if docking a floating strip to a CommandBar control. The C# Code snippet below shows how to use the FloatingStripDocked event.

void commandBar1_FloatingStripDocked(object sender, EventArgs e)
{
CommandBarStripElement dockedStrip = sender as CommandBarStripElement;
if (dockedStrip != null)
{
MessageBox.Show(dockedStrip.Name + " dock " + dockedStrip.ElementTree.Control.Name);
}
}
UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls