Change Location on Runtime

Hi. I want to change the location of the label (move on the statusbarstrip to left or right) which is on the statusbarstrip during resizing of the mdiform. Thanks
gokhanozAsked:
Who is Participating?
 
Bob LearnedCommented:
I set up a simple test form with 2 labels, adding a spacer label to the left:

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.AdjustSpacing()
    End Sub

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

    Private Sub AdjustSpacing()
        Me.Label2.Width = Me.StatusStrip1.Width - Me.Label1.Width - 20
    End Sub

End Class

The width of the left label, pushes the display label to the right to a position where it is anchored to the right side of the StatusStrip.

Bob
0
 
Bob LearnedCommented:
1) Are you talking about a Label on the StatusBarStrip itself?

2) Setting a control's location to a point:
Me.Label1.Location = New Point(50, 50)

3) You could set the anchor, like Bottom, Right to keep the label stuck to the bottom-right side of the screen

Bob
0
 
gokhanozAuthor Commented:
OK but anchor is not present in the property list. And the location is not seems to be a member of it.
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
Bob LearnedCommented:
So you are talking about a Label control on the StatusBarStrip.  How do you want to change the location of the label?

Bob
0
 
gokhanozAuthor Commented:
Statusbarstrip is on the MDIparent form, and  label control is on that statusbarstrip. I want to use anchor property to stuck the control to the rigth side of the screen. But it seems that anchor is not presenet on the property list.  So I prefer to move that control to that right or the left depending the new shape of the mdiparent. Thats what I want to do. Thanks.
0
 
Bob LearnedCommented:
While the Anchor is not a browsable property, you can set it in code (at run-time):

Me.Label1.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right

Bob
0
 
gokhanozAuthor Commented:
Bob, I am sorry but its not working. I am testing like that, I added a button, in the click event I wrote that code, and tested on run-time. label is keeping its original position..
0
 
Bob LearnedCommented:
How many other controls are on the StatusStrip control?

Bob
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.