Permalink
Fetching contributors…
Cannot retrieve contributors at this time
52 lines (44 sloc) 3.63 KB
title ms.custom ms.date ms.prod ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager
How to: Use the Spring Property Interactively in a StatusStrip
03/30/2017
.net-framework
dotnet-winforms
article
jsharp
StatusStrip control [Windows Forms]
ToolStrip control [Windows Forms]
status bars, examples
Spring property [Windows Forms]
18bde842-a93c-48dd-9db3-15738a1775ce
9
dotnet-bot
dotnetcontent
wpickett

How to: Use the Spring Property Interactively in a StatusStrip

You can use the xref:System.Windows.Forms.ToolStripStatusLabel.Spring%2A property to position a xref:System.Windows.Forms.ToolStripStatusLabel control in a xref:System.Windows.Forms.StatusStrip control. The xref:System.Windows.Forms.ToolStripStatusLabel.Spring%2A property determines whether the xref:System.Windows.Forms.ToolStripStatusLabel control automatically fills the available space on the xref:System.Windows.Forms.StatusStrip control.

Example

The following code example demonstrates how to use the xref:System.Windows.Forms.ToolStripStatusLabel.Spring%2A property to position a xref:System.Windows.Forms.ToolStripStatusLabel control in a xref:System.Windows.Forms.StatusStrip control. The xref:System.Windows.Forms.ToolStripItem.Click event handler performs an exclusive-or (XOR) operation to switch the value of the xref:System.Windows.Forms.ToolStripStatusLabel.Spring%2A property.

To use this code example, compile and run the application, and then click Middle (Spring) on the xref:System.Windows.Forms.StatusStrip control to switch the value of the xref:System.Windows.Forms.ToolStripStatusLabel.Spring%2A property.

[!code-csharpSystem.Windows.Forms.ToolStrip.Misc#1] [!code-vbSystem.Windows.Forms.ToolStrip.Misc#1]
[!code-csharpSystem.Windows.Forms.ToolStrip.Misc#50] [!code-vbSystem.Windows.Forms.ToolStrip.Misc#50]

Compiling the Code

This example requires:

  • References to the System.Design, System.Drawing, and System.Windows.Forms assemblies.

For information about building this example from the command line for [!INCLUDEvbprvb] or [!INCLUDEcsprcs], see Building from the Command Line or Command-line Building With csc.exe. You can also build this example in [!INCLUDEvsprvs] by pasting the code into a new project. Also see How to: Compile and Run a Complete Windows Forms Code Example Using Visual Studio.

See Also

xref:System.Windows.Forms.ToolStripStatusLabel
xref:System.Windows.Forms.StatusStrip
xref:System.Windows.Forms.ToolStrip
xref:System.Windows.Forms.ToolStripItem
xref:System.Windows.Forms.ToolStripMenuItem
ToolStrip Control