Removing Small Space on StatusStrip

回答済み Removing Small Space on StatusStrip

  • 2012年3月20日 16:48
     
     
    I 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.

すべての返信

  • 2012年3月20日 17:56
     
     
    Was I clear enough?
  • 2012年3月20日 18:20
     
     
    The last Item is pushed all the way to the right.
    What does that mean?
  • 2012年3月21日 13:46
     
     

    The last Item is pushed all the way to the right.

    What does that mean?
    I have a string.empty label with spring set to true so it will push the 3rd item all the way to the right.
  • 2012年3月21日 14:04
     
      コードあり

    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
    

  • 2012年3月21日 14:30
     
      コードあり

    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

  • 2012年3月21日 15:13
     
     

    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.

  • 2012年3月21日 19:19
     
     
    I 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)
  • 2012年3月21日 19:32
     
     回答済み コードあり

    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