Status bar with Labels

lpaul

Active member
Joined
Dec 7, 2005
Messages
27
Programming Experience
Beginner
I have a status bar on a form and four labels above each panel. I need help with coding the labels to move (resize) with the statusbar panels. :confused:
 
jmcilhinney said:
He has a StatusBar at the bottom of the form with several StatusBarPanels. Above that, on the form surface (not in front of, as in z-order, but vertically above) he has the same number of Labels as StatusBarPanels. He wants each Label to relocate and/or resize to remain in the same position relative to the corresponding StatusBarPanel.

Oh i see now thanks John

ok, Paul give me some time and i'll make a demo for you ;)
 
I am afraid i still don't get it ... it seems like an unique idea :D
However i hope you will find some sense for further coding. Ask whatever you want but next time care to be more precisely please

Regards ;)

Note: this work only when you resize the form and i think you need to set up the statusparpanel's autosize property to "content" and change the label's size respectively
 

Attachments

This will keep the Labels sized and aligned with the corresponding StatusBarPanels. You would also need to call the SetLabelLocations method whenever the Text of a StatusBarPanel was changed, but it would have to be done manually as there is no TextChanged event for the StatusBarPanel class.
VB.NET:
Expand Collapse Copy
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.SetLabelLocations()
    End Sub

    Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
        Me.SetLabelLocations()
    End Sub

    Private Sub SetLabelLocations()
        Me.Label1.Left = 0
        Me.Label1.Width = Me.StatusBarPanel1.Width
        Me.Label2.Left = Me.Label1.Right
        Me.Label2.Width = Me.StatusBarPanel2.Width
        Me.Label3.Left = Me.Label2.Right
        Me.Label3.Width = Me.StatusBarPanel3.Width
        Me.Label4.Left = Me.Label3.Right
        Me.Label4.Width = Me.StatusBarPanel4.Width
    End Sub
 

Attachments

  • StatusBarLabels.JPG
    StatusBarLabels.JPG
    7.7 KB · Views: 85
For those who were lazy to open my attachment this is the code i made there:
VB.NET:
Expand Collapse Copy
[SIZE=2]Label1.Size = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Size([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].StatusBar1.Panels.Item(0).Width, 20)
Label2.Size = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Size([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].StatusBar1.Panels.Item(1).Width, 20)
Label2.Left = [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Label1.Width
Label3.Size = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Size([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].StatusBar1.Panels.Item(2).Width, 20)
Label3.Left = [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Label1.Width + [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Label2.Width
Label4.Size = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Size([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].StatusBar1.Panels.Item(3).Width, 20)
Label4.Left = [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Label1.Width + [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Label2.Width + [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Label3.Width
[/SIZE]
the point is that there is always another way to acomplish the same task

Regards ;)
 
Back
Top