Tool Strip Status Label Align Right Vb.net

On
  1. Tool Strip Status Label Align Right C#
  2. See More On Stackoverflow

AutoSize = false;.Set the xref:System.Windows.Forms.ToolStripItem.Size%2A property the way you want for the associated xref:System.Windows.Forms.ToolStripItem.To set the spacing of a ToolStripItem.Insert the desired values, in pixels, into the xref:System.Windows.Forms.ToolStripItem.Margin%2A property of the associated control.The values of the xref:System.Windows.Forms.ToolStripItem.Margin%2A property specify the spacing between the item and adjacent items in this order: Left, Top, Right, and Bottom. Margin = new System.

Align

Padding( 3, 0, 3, 0);To align a ToolStripItem to the right side of the ToolStrip.Set the xref:System.Windows.Forms.ToolStripItem.Alignment%2A property to xref:System.Windows.Forms.ToolStripItemAlignment.Right for the associated control. By default, xref:System.Windows.Forms.ToolStripItem.Alignment%2A is set to xref:System.Windows.Forms.ToolStripItemAlignment.Left, which aligns controls to the left side of the xref:System.Windows.Forms.ToolStrip.

Windows Forms StatusStrip ControlA typical status bar control, placed on the bottom of a Form is used to display some text that represents a status of the application and user actions. In the previous versions of the Windows Forms, the StatusBar control is used to provide the status bar functionality. In Windows Forms 4.0 that is a part of Visual Studio 2010, the StatusStrip control replaces the StatusBar control. The StatusStrip control not only provides status bar functionality but also provides features to add rich user interfaces to a status bar such as a ProgressBar, DropDownButton and SplitButton controls.In this article, we will learn how to build status bar enabled Windows applications using Visual Studio 2010.Similar to any other Windows Forms control, we can use either use design-time approach or runtime approach to create a StatusStrip control. The design-time approach is used in the most of the cases but there will be times when we may need the run-time approach.NoteIn this tutorial, I use the design-time approach as the default approach but I will also show the run-time approach side by side.Creating a StatusStripTo build a StatusStrip control at design-time, simply drag and drop a StatusStrip control from the Toolbox to the Form. The default StatusStrip control is docked at the bottom of the Form as shown in Figure 1.

StatusStrip dynamicStatusStrip = new System.Windows.Forms.StatusStrip;. // Set StatusStrip properties, methods, and events. // Add StatusStrip child controls. Controls.Add(dynamicStatusStrip);Listing 1StatusStrip PropertiesThe StatusStrip class is inherited from the ToolStrip -ScrollableControl-Control classes and hence has all of the common properties supported by a Windows Forms control. Some of these common properties include Font, BackColor, Dock, BackgroundImage, and TextDirection.We can set the StatusStrip control properties using the Properties Window that looks like Figure 3. StatusStrip dynamicStatusStrip = new System.Windows.Forms.StatusStrip;.

dynamicStatusStrip.Name = 'DynamicStatusStrip';. dynamicStatusStrip.Text = 'statusStrip1';. dynamicStatusStrip.BackColor = Color.OrangeRed;. dynamicStatusStrip.Font = new Font( 'Georgia', 14, FontStyle.Italic);.

dynamicStatusStrip.ForeColor = Color.White;Listing 2Docking a StatusStripUnlike the old StatusBar control, now we can dock a StatusStrip control on a Form. The Dock property of the StatusStrip is used to set docking. A StatusStrip control can be docked at top, bottom, left, right, or center.Figure 4 shows a top docked StatusStrip control. dynamicStatusStrip.Dock = DockStyle.Top;Listing 3Background ImageThe BackColor property sets the background color of a StatusStrip control. We can also set an image as the background color of a StatusStrip control. The BackgroundImage property is used to set the background image of a StatusStrip control. When you click on the BackgroundImage property in the Property designer, you will see the Resource Editor that looks like Figure 5, where you can browse an image or use local resources using the Import button.

Figure 5We can also set the layout of the background image using the BackgroundImageLayout property that can be stretched, tiled, centered, centered or zoomed as you can see in Figure 6.Figure 6Run-timeThe BackgroundImage property takes an Image type. We can use an ImageList to manage all the images. An ImageList is an object of Image objects. The code snippet in Listing 4 creates an ImageList object and adds an image to it from a file. The code then sets the BackgroundImage and BackgroundImageLayout properties. ImageList dynamicImgList = new ImageList;dynamicImgList.Images.Add(Image.FromFile(@ 'C:ImagesNeel18.jpg' ));. dynamicStatusStrip.BackgroundImage = dynamicImgList.Images0;.

dynamicStatusStrip.BackgroundImageLayout = ImageLayout.Center;Listing 4Text DirectionThe TextDirection is another useful property that was missing in the StatusBar control. Using the TextDirection property, we can set the text direction of the StatusStrip control. It has three properties – Horizontal, Vertical90 and Vertical270. Figure 7 shows Verical90 text of a StatusStrip control. dynamicStatusStrip.TextDirection = ToolStripTextDirection.Vertical270;Listing 5Sizing Grip, Grip Style, and Layout StyleThe sizing grip is a little sizing handle in the lower right corner of a control. Using the SizingGrip property is used to enable the sizing handle. The SizingGrip property works with the GripStyle and the LayoutStyle properties.

Tool Strip Status Label Align Right C#

The GripStyle property is used to show or hide the grip style. The LayoutStyle property as shown in Figure 8 represents the layout type of the grip. dynamicStatusStrip.SizingGrip = true;. dynamicStatusStrip.GripStyle = ToolStripGripStyle.Visible;. dynamicStatusStrip.LayoutStyle = ToolStripLayoutStyle.HorizontalStackWithOverflow;Listing 6Adding StatusStrip ItemsA StatusStrip control is nothing but a container for the child controls. A StatusStrip control can host several child controls.

See More On Stackoverflow

These child controls are represented by the Items property. If you click on the Items property of the StatusStrip control, you will see Items Collection Editor where you can add, update, and delete the child controls. If you click on the Items property, you will see the Item Collection Editor where you can select an item type from the DropDown and click Add button to add the child control. The DropDown has four item types and these items are the ToolStripStatusLabel, ToolStripProgressBar, ToolStripDropDownButton, and ToolStripSplitButton.Now, let's add one item of each control type as you can see from Figure 9. Once you add an item, you will see all the properties in the right side properties window. Figure 11StatusBar Enabled ApplicationAlright!

Let's build a StatusBar enabled application.I create a Windows Forms application and add a StatusStrip control to the Form. I also add three Button controls to the Form. After that, I add two StatusStripStatusLabel, one StatusStripDropDownButton, and one StatusStripProgressBar child controls to the Form.Now I add three menu items to the StatusStripDropDownButton by using its Items property and change its text and foreground colors to Red, Green, and Blue. I also add the Click event handlers for these menu items. The event handler of menu items looks like following.