Remembering startPosition

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • robertybob
    New Member
    • Feb 2013
    • 116

    Remembering startPosition

    Hi

    At the moment I am using centerParent to open forms in most cases but it is a mess and totally random.

    In most applications I use, windows appear in the same location that they were last opened even after closing everything down for days.

    I would like to have a form open exactly where it was last opened. Is this a simple case of setting something on the form or do I need to code some fancy instructions and save to a file?

    Thanks!
  • robertybob
    New Member
    • Feb 2013
    • 116

    #2
    Wow - I'm stunned this has no simple answer. Guess I should have been alerted to that by fact I couldn't Google a solution! I use VB applications that store locations but guess this is done by storing data in a file.

    Comment

    • robertybob
      New Member
      • Feb 2013
      • 116

      #3
      Actually think might have solved this - using different search terms.

      1.Click the Project Properties and then click the Settings tab.

      2.In the Settings tab, set the Name to MainFormLocatio n and set the Type to System.Drawing. Point.

      3.Open the Form’s properties and expand its Application Settings property. Find the Location property and set its value to MainFormLocatio n from the drop down list.

      This seems to work. Thanks to Irina at TechRepublic

      Comment

      • robertybob
        New Member
        • Feb 2013
        • 116

        #4
        Hmm - seems to work within the same application run but doesn't save the location when application is closed and run again.

        Comment

        • robertybob
          New Member
          • Feb 2013
          • 116

          #5
          Seems I also needed to include the following in the form load.

          Me.Location = My.Settings.Mai nFormLocation

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Hi robertybob.

            Sorry to see you never found your answer here. However, I'd say that looks like VB.Net code, and this is the VB6 forum. That may have had an effect.

            Also, you may be searching for the wrong terms. After all, you've seen that placing your form in a particular location is easy enough. Your problem is simply getting the information to persist over multiple executions of your program.

            A couple of thoughts come to mind. First, you could store the information in a file in, say, your application folder. Just read the file again when you start up, and move your form. Second, and probably the better solution, would be to store the information in the Windows registry. I won't attempt to explain how, because that's one area where VB6 and VB.Net are very different (I don't remember the VB6 way anyhow, but don't tell anyone).

            Comment

            Working...