?
Solved

Binding form location with application settings

Posted on 2009-04-14
3
Medium Priority
?
462 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month15 days, 12 hours left to enroll

850 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