Click here to Skip to main content
15,881,588 members

VB.NET 2008 SortedList and Settings File

JulianDimitrov asked:

Open original thread
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
Tags: Visual Basic (Visual Basic 9 (2008))

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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