SET SIZE OF FORM AT RUNTIME

Hi All,

I have below code :

  Me.Left = 0
        Me.Top = 5

        Me.Width = Screen.PrimaryScreen.Bounds.Width - 10
        Me.Height = Screen.PrimaryScreen.Bounds.Height - 90

At what event should I put it and why ?

Thank you.
LVL 1
emi_sastraAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
You can put it in the Load() event of the form, but should probably also set the StartPosition() to Manual:
Public Class Form1

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Me.StartPosition = FormStartPosition.Manual
        Me.Left = 0
        Me.Top = 5

        Me.Width = Screen.PrimaryScreen.Bounds.Width - 10
        Me.Height = Screen.PrimaryScreen.Bounds.Height - 90
    End Sub

End Class

Open in new window

0
 
emi_sastraAuthor Commented:
Hi Idle_Mind,

  Me.StartPosition = FormStartPosition.Manual

What is it for ?

Thank you.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
That keeps the form from being positioned automatically by the operating system itself.
0
 
emi_sastraAuthor Commented:
Ok.

Thank you very much for your help.
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.