Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Setting a form's location and size

Setting a form's location and size

Scheduled Pinned Locked Moved Visual Basic
question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SerialHobbyist
    wrote on last edited by
    #1

    Is it possible to set a form's location and size before displaying it? I have a couple of resizable forms in my current project. I'd like to have the app remember the size and location of the forms when the user last closed them.

    D 1 Reply Last reply
    0
    • S SerialHobbyist

      Is it possible to set a form's location and size before displaying it? I have a couple of resizable forms in my current project. I'd like to have the app remember the size and location of the forms when the user last closed them.

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      I'll leave the part about saving and retrieving the values up to you since there are so many methods of saving these values somewhere... You can set the Size, Location and StartPosition properties of the form before you call the form's Show or ShowDialog method:

      Dim newForm As New Form2
      

      newForm.Size = New Size(100, 200)
      newForm.StartPosition = FormStartPosition.Manual
      newForm.Location = New Point(50, 50)
       
      newForm.Show()

      RageInTheMachine9532

      S 1 Reply Last reply
      0
      • D Dave Kreskowiak

        I'll leave the part about saving and retrieving the values up to you since there are so many methods of saving these values somewhere... You can set the Size, Location and StartPosition properties of the form before you call the form's Show or ShowDialog method:

        Dim newForm As New Form2
        

        newForm.Size = New Size(100, 200)
        newForm.StartPosition = FormStartPosition.Manual
        newForm.Location = New Point(50, 50)
         
        newForm.Show()

        RageInTheMachine9532

        S Offline
        S Offline
        SerialHobbyist
        wrote on last edited by
        #3

        Perfect. And by inserting the middle three lines into the Load event, and changing 'newForm' to 'Me', I've managed to change the main form as well. Don't worry about the saving - I've got that bit sorted out. Thanks for your help.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups