Click here to Skip to main content
15,909,530 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: My.Settings Pin
Herboren2-Oct-10 4:38
Herboren2-Oct-10 4:38 
AnswerRe: My.Settings Pin
Dave Kreskowiak2-Oct-10 4:38
mveDave Kreskowiak2-Oct-10 4:38 
GeneralRe: My.Settings Pin
Herboren2-Oct-10 5:00
Herboren2-Oct-10 5:00 
AnswerRe: My.Settings Pin
Luc Pattyn2-Oct-10 5:38
sitebuilderLuc Pattyn2-Oct-10 5:38 
GeneralRe: My.Settings Pin
Herboren2-Oct-10 5:44
Herboren2-Oct-10 5:44 
JokeRe: My.Settings Pin
DaveAuld2-Oct-10 5:57
professionalDaveAuld2-Oct-10 5:57 
GeneralRe: My.Settings Pin
Herboren2-Oct-10 7:34
Herboren2-Oct-10 7:34 
AnswerRe: My.Settings Pin
DaveAuld2-Oct-10 5:54
professionalDaveAuld2-Oct-10 5:54 
Look at the code below. This works fine.

In the Settings, the listbox items to be stored should be saved in type Specialized String Collection;

VB
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Add items from Settings to listbox
        updateList()
    End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Remove Item from List and update Settings
        If ListBox1.SelectedIndices.Count > 0 Then
            ListBox1.Items.RemoveAt(ListBox1.SelectedIndices(0))
        End If

        'New item list
        Dim newlist As New Specialized.StringCollection
        For Each item In ListBox1.Items
            newlist.Add(item)
        Next
        My.Settings.Item("theList") = newlist
        My.Settings.Save()

        'This is just a test to show the settings have been saved, by reloading them back into the listbox
        updateList()
End Sub


Private Sub updateList()
        'Add items from Settings to listbox
        ListBox1.Items.Clear()

        For Each item As String In My.Settings.Item("theList")
            ListBox1.Items.Add(item)
        Next
End Sub

Dave
Find Me On: Web|Facebook|Twitter|LinkedIn

CPRepWatcher now available as Packaged Chrome Extension, visit my articles for link.

GeneralRe: My.Settings Pin
Herboren3-Oct-10 5:06
Herboren3-Oct-10 5:06 
GeneralRe: My.Settings Pin
DaveAuld3-Oct-10 8:10
professionalDaveAuld3-Oct-10 8:10 
QuestionGregorian date to convert solar (Tarikh Shamsi) Pin
saywan161-Oct-10 2:18
saywan161-Oct-10 2:18 
QuestionRe: Gregorian date to convert solar (Tarikh Shamsi) PinPopular
Luc Pattyn1-Oct-10 2:39
sitebuilderLuc Pattyn1-Oct-10 2:39 
Questionvb.net listview & arrays Pin
Central_IT30-Sep-10 11:10
Central_IT30-Sep-10 11:10 
AnswerRe: vb.net listview & arrays Pin
Luc Pattyn30-Sep-10 11:57
sitebuilderLuc Pattyn30-Sep-10 11:57 
QuestionUDP socket on the same host.. Pin
jainiraj28-Sep-10 18:29
jainiraj28-Sep-10 18:29 
QuestionKitchen Printer Pin
εїзεїзεїз27-Sep-10 20:37
εїзεїзεїз27-Sep-10 20:37 
AnswerRe: Kitchen Printer Pin
Dave Kreskowiak28-Sep-10 1:45
mveDave Kreskowiak28-Sep-10 1:45 
GeneralRe: Kitchen Printer Pin
εїзεїзεїз28-Sep-10 23:05
εїзεїзεїз28-Sep-10 23:05 
GeneralRe: Kitchen Printer Pin
Dave Kreskowiak29-Sep-10 2:12
mveDave Kreskowiak29-Sep-10 2:12 
GeneralRe: Kitchen Printer Pin
εїзεїзεїз29-Sep-10 2:57
εїзεїзεїз29-Sep-10 2:57 
QuestionGetCursorPos Pin
Win32SF27-Sep-10 18:59
Win32SF27-Sep-10 18:59 
AnswerRe: GetCursorPos Pin
Dave Kreskowiak28-Sep-10 1:42
mveDave Kreskowiak28-Sep-10 1:42 
GeneralRe: GetCursorPos Pin
Win32SF28-Sep-10 5:08
Win32SF28-Sep-10 5:08 
GeneralRe: GetCursorPos Pin
Dave Kreskowiak28-Sep-10 6:03
mveDave Kreskowiak28-Sep-10 6:03 
GeneralRe: GetCursorPos Pin
Win32SF28-Sep-10 12:32
Win32SF28-Sep-10 12:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.