Reputation: 4655
I have Form with StatusBar on it. On StatusBar there are ToolStripStatusLabel1 and ToolStripProgressBar1. Normaly, ToolStripProgressBar is not visible.
But when I start file copying ToolStripStatusLabel1 becames invisible and ToolStripProgressBar becames visible.
like this:
ToolStripStatusLabel1.Visible = False
ToolStripProgressBar1.Visible = True
Problem is that in this condition I cant get that ProgressBar take all the space of StatusBar not with increasing it's width nor with setting it's Dock property to .Fill.
ToolStripStatusLabel1.Visible = False
ToolStripStatusLabel1.Width = 0
ToolStripProgressBar1.Dock = DockStyle.Fill
Is it possible to get ToolStripProgressBar1 to take full Width of StatusBar in described situation?
Upvotes: 0
Views: 246
Reputation: 39122
The ToolStripProgressBar is quite limited and can't do what you want.
An alternative is to make a regular ProgressBar take the place of your entire StatusStrip:
Public Class Form1
Private PB As New ProgressBar
Private ShowProgress As Boolean = False
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
ShowProgressBar(True)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
ShowProgressBar(False)
End Sub
Private Sub ShowProgressBar(ByVal Visible As Boolean)
ShowProgress = Visible
If ShowProgress Then
Dim rc As Rectangle = StatusStrip1.RectangleToScreen(StatusStrip1.ClientRectangle)
PB.Bounds = Me.RectangleToClient(rc)
PB.Anchor = AnchorStyles.Left Or AnchorStyles.Right Or AnchorStyles.Bottom
Me.Controls.Add(PB)
PB.BringToFront()
Else
Me.Controls.Remove(PB)
End If
End Sub
End Class
Upvotes: 1