Click here to Skip to main content
13,054,615 members (59,030 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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"
       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
   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,
Posted 18-Nov-10 3:14am
Updated 18-Nov-10 20:29pm
losmac 25-Nov-10 14:41pm
Debug program and check for mObjectCollection value. Maybe mObjectCollection is equal Nothing!
And look here:

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 19 Nov 2010
Copyright © CodeProject, 1999-2017
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