Click here to Skip to main content
15,885,740 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
VB
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:
VB
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 :(

Thank You in advance,
Julian
Posted
Updated 18-Nov-10 20:29pm
v3
Comments
Maciej Los 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900