Resize Form with a Right Anchor VB.Net

249 Views Asked by At

I'm trying to resize a borderless form so that the right hand side stays where it is and the left hand border is what is adjusted. I don't think I'm using the below correctly for VB.net, but for other programs you can set the anchor to 0 to 1 depending on where you want to anchor the control (0 being left, 0.5 being middle and 1 being right).

Private Sub Form1_Click(sender As Object, e As EventArgs) Handles Me.Click

    Me.Anchor = AnchorStyles.Right
    Me.Size = New Size(Me.Width / 2, Me.Height)

End Sub

I know that I achieve what I desire using the below, but wanted to know if form anchoring is possible? Does anybody know if this is possible? Many thanks

Private Sub Form1_Click(sender As Object, e As EventArgs) Handles Me.Click

    Me.Size = New Size(Me.Width / 2, Me.Height)
    Me.Location = New Point(Me.Location.X + Me.Width, Me.Location.Y)

End Sub
1

There are 1 best solutions below

0
On

You can anchor a control within the form or other container in vb.net, but not the form itself. Here's one other way to accomplish it.