Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB9.0 VB VB.NET
Hi,
I've a problem that I can't solve. Here it is:
Using Visual Studio 2008 SP1, Windows 7 Ultimate.
I'm filling one SortedList with Objects (Buttons), I've created one Settings file called Settings1, and added "Name" - "AddedControls", for "Type" I choose "System.Collections.SortedList", the "Scope" is "User".
Here is the code for filling the SortedList:
Private Sub pnlWorkSpace_DragDrop1(ByVal sender As Object, ByVal e As DragEventArgs) Handles pnlWorkSpace.DragDrop
       Dim dropX As Single = e.X
       Dim dropY As Single = e.Y
 
       Dim NewButton As New Button
       NewButton = CType(Me.mCurrentObject, Button)
       NewButton.Text = "Added"
       Me.Controls.Add(NewButton)
       pbWorkspace.SendToBack()
       pnlWorkSpace.SendToBack()
       Dim dropLocation = New Point(dropX - NewButton.Size.Width \ 2, dropY - NewButton.Size.Height \ 2)
       Dim dropPoint As New Point()
       dropPoint = Me.PointToClient(dropLocation)
       NewButton.Location = dropPoint
       mObjectCollection.Add(NewButton.TabIndex, NewButton)
       AddHandler NewButton.MouseDown, AddressOf NewButton_MouseDown
 
   End Sub
 
The code for adding the SortedList in the Settings1 file is:
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Settings1.Default.AddedControls = mObjectCollection
        Settings1.Default.Save()
   End Sub
When I run the application, I fill the form with some buttons, then I pres the "Save" button and it appears that the "mObjectCollection" is transfered in "Settings1.Default.AddedControls", but when I stop the application and run it again the "Settings1.Default.AddedControls" has value "Nothing".
 
Can anyone explain why that happens and what am I doing wrong.
 
Today, I've tried step by step mode in line "Settings1.Default.Save()", and when the pointer passed trough,I've looked at my projects folder where the Settings1.settings file is situated, and the "Date modified" option did not changed. I'm confused Frown | :(
 
Thank You in advance,
Julian
Posted 18-Nov-10 4:14am
Edited 18-Nov-10 21:29pm
v3
Comments
losmac at 25-Nov-10 14:41pm
   
Debug program and check for mObjectCollection value. Maybe mObjectCollection is equal Nothing!
And look here: http://msdn.microsoft.com/en-us/library/a65txexh%28VS.80%29.aspx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,803
1 Sergey Alexandrovich Kryukov 6,377
2 DamithSL 5,421
3 Manas Bhardwaj 4,841
4 Maciej Los 4,330


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 19 Nov 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100