Removing Small Space on StatusStrip
-
Tuesday, March 20, 2012 4:48 PMI have been search for an answer to this and cant seem to find anything. There is a gap on my statusStrip to the right of the last item. The last Item is pushed all the way to the right. Please see my attachment.
All Replies
-
Tuesday, March 20, 2012 5:56 PMWas I clear enough?
-
Tuesday, March 20, 2012 6:20 PM
The last Item is pushed all the way to the right.
What does that mean? -
Wednesday, March 21, 2012 1:46 PM
I have a string.empty label with spring set to true so it will push the 3rd item all the way to the right.The last Item is pushed all the way to the right.
What does that mean? -
Wednesday, March 21, 2012 2:04 PM
Well it looks like it is leaving room for the sizing grip so there's not much you can do about that.
You could get rid of the spring label and use something like this:
Private Sub StatusStrip1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles StatusStrip1.Resize ToolStripStatusLabel2.Width = StatusStrip1.Width - ToolStripStatusLabel1.Width - 6 End Sub -
Wednesday, March 21, 2012 2:30 PM
Nice trick!
Actually you don't need that -6 there. Use the ClientSize or ClientRectangle instead, to get the inner area dimensions.
Private Sub StatusStrip1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles StatusStrip1.Resize ToolStripStatusLabel1.Width = StatusStrip1.ClientSize.Width - ToolStripStatusLabel2.Width End Sub
Pradeep, Microsoft MVP (Visual Basic)
http://pradeep1210.wordpress.com -
Wednesday, March 21, 2012 3:13 PM
Thanks
I only put the 6 in to allow a small gap to remain, if required. I don't think it matters whether you use ClientSize.Width or just Width as the status strip doesn't have a border.
Swapping the labels over as you have is probably what he really wanted to do.
-
Wednesday, March 21, 2012 7:19 PMI could not get this to work for me, it just pushed the label to the left I want the one that is on the right already squeezed to the boarder of the form (or end of the status strip)
-
Wednesday, March 21, 2012 7:32 PM
Have you turned off AutoSizing.
Try this in a new project:
Public Class Form1 Dim WithEvents SS As New StatusStrip Dim Label1 As New ToolStripStatusLabel("Label One") Dim Label2 As New ToolStripStatusLabel("Label Two") Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load SS.SizingGrip = False Label1.AutoSize = False SS.Items.Add(Label1) SS.Items.Add(Label2) Controls.Add(SS) End Sub Private Sub SS_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles SS.Resize Label1.Width = SS.Width - Label2.Width End Sub End Class- Proposed As Answer by Mark Liu-lxfModerator Thursday, March 22, 2012 3:06 AM
- Marked As Answer by dakota367 Thursday, March 22, 2012 2:50 PM

