• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 244
  • Last Modified:

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.
0
emi_sastra
Asked:
emi_sastra
  • 2
  • 2
1 Solution
 
Mike TomlinsonMiddle 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.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now