Solved

Binding form location with application settings

Posted on 2009-04-14
3
443 Views
Last Modified: 2012-05-06
In VB2008 Express, I've added an application setting for MainFormLocation and in the form's application settings I've bound the location to MainFormLocation as described at http://blogs.techrepublic.com.com/programming-and-development/?p=540
However, although the form loads at the co-ordinates set in the application settings MainFormLocation x/y settings, if I move the form and close it then the x/y settings don't save and change.

Any ideas please?
0
Comment
Question by:ncw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 15

Expert Comment

by:oobayly
ID: 24142354
You'll have to handle the LocationChanged event, then just update & save the settings
Private Sub Form_LocationChanged(ByVal sender As Object, ByVal e As EventArgs)
    My.Settings.Default.MainFormLocation = Me.Location
    My.Settings.Default.Save()
End Sub

Open in new window

0
 
LVL 15

Accepted Solution

by:
oobayly earned 500 total points
ID: 24142440
Sorry, it's a little different from C#. I don't think Default is needed
    Private Sub Form1_LocationChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LocationChanged
        My.Settings.MainFormLocation = Me.Location
        My.Settings.Save()
    End Sub

Open in new window

0
 
LVL 1

Author Closing Comment

by:ncw
ID: 31569961
Yes this works well, thanks!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question