Solved

Binding form location with application settings

Posted on 2009-04-14
3
440 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
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual Studio editor? 1 38
Problem to error 4 47
Class object 2 28
Advice on Xojo as a development tool over VB. 4 41
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)…
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 …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 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

24 Experts available now in Live!

Get 1:1 Help Now