Solved

Binding form location with application settings

Posted on 2009-04-14
3
438 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
  • 2
3 Comments
 
LVL 15

Expert Comment

by:oobayly
Comment Utility
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
Comment Utility
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
Comment Utility
Yes this works well, thanks!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now