Solved

Binding form location with application settings

Posted on 2009-04-14
3
444 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

705 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