|
-
Jan 26th, 2008, 01:01 PM
#1
Thread Starter
Fanatic Member
-
Jan 26th, 2008, 01:51 PM
#2
Re: My.Settings not saving.
Dont worry about the serializeAs="String" tag, thats just the way it always "does".
If you want the location of the form to be set from the settings at startup and saved to the settings at shutdown, theres a simple way:
Create a setting of type System.Drawing.Point.
In the form properties, select (ApplicationSettings) and then (PropertyBinding).
In the dialog that appears, choose the Location property and select the newly created setting in the dropdownlist.
The forms Location property is now bound to the setting
-
Jan 26th, 2008, 02:34 PM
#3
Thread Starter
Fanatic Member
Re: My.Settings not saving.
Oh, the forms position isn't the problem. That could be easily fixed.
But why doesn't the my.settings work?
-
Jan 26th, 2008, 10:42 PM
#4
Re: My.Settings not saving.
Please provide a list of steps that we can perform to reproduce the issue, starting with a new project.
-
Jan 27th, 2008, 09:03 AM
#5
Thread Starter
Fanatic Member
Re: My.Settings not saving.
Umm, i've tried to replicate the problem... but have failed. Though this is not the first time it has happened and it's a completely new program i had started to make.
Any way, i've uploaded the project, perhaps you could find out why it's doing it, how to fix, or how to prevent.
http://www.megafileupload.com/en/fil...Timer-rar.html
In the mean time, i'm just going to start the program again and copy what i have already started. But i would still like to know how to fix this problem instead of running from it. Also on a side note, this problem has happened before, on one particular program i was making it would save Integer values, but it wouldn't save Strings. I had all the variable types set properly and that too.
Thank you =).
Last edited by Slyke; Jan 27th, 2008 at 09:10 AM.
-
Jan 27th, 2008, 09:24 AM
#6
Thread Starter
Fanatic Member
Re: My.Settings not saving.
OK, I got it to replicate the error, twice now:
This is what i did:
1. Create a new project
2. Copy all the controls from the old project (Using Ctrl+A, Ctrl+C)
3. Pasted All the controls (Ctrl+V)
4. Resized the form to fit the controls.
5. Changed the Form's MaximizeBox Property to False
6. Changed the Form's FormBorderStyle to FixedSingle
7. Renamed the form to "FrmMain"
8. Changed the forms filename to "FrmMain" (In Visual Basic of course).
9. Changed the Root Namespace and Assembly name to "Shutdown".
10. Went into settings and put in FrmMainX and FrmMainY and made them both as integers.
11. Pasted the following code into the form:
vb Code:
Private Sub CmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdExit.Click My.Settings.FrmMainX = Me.Left My.Settings.FrmMainY = Me.Top Dim I As Integer For I = 1000 To 1 Step -1 Me.Opacity = I / 100 Application.DoEvents() Next Me.Opacity = 0 Me.Hide() End End Sub Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed CmdExit_Click(CmdExit, e) End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Left = My.Settings.FrmMainX Me.Top = My.Settings.FrmMainY End Sub
12. Started it and closed the form, started it again and it was back at the default position.
By the way, It didn't matter if the Form1_Load and Form1_FormClosed subs were named FrmMain_Load and FrmMain_FormClosed. It still happens
Last edited by Slyke; Jan 27th, 2008 at 09:28 AM.
-
Jan 27th, 2008, 09:52 AM
#7
Thread Starter
Fanatic Member
Re: My.Settings not saving.
Adding in My.Settings.Save seems to fix this problem.
But it saves without My.Settings.Save Sometimes too! If no one has anything to say to this I'll mark the thread resolved.
-
Jan 27th, 2008, 05:01 PM
#8
Re: [RESOLVED] My.Settings not saving.
Have you set the StartPosition property of the form to Manual? If not then manually setting the Location will have no effect as the form will be shown initially where the StartPosition property tells it to be.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|