Results 1 to 4 of 4

Thread: [2005] My.settings with Listbox

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2007
    Posts
    24

    [2005] My.settings with Listbox

    Can I save a listbox to my.settings? If so how?

    Thank you,
    Adam

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] My.settings with Listbox

    A ListBox is a control. You can't save a control as an application setting. What you can do is create an application setting of type StringCollection and bind that to the ListBox's DataSource property.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2007
    Posts
    24

    Re: [2005] My.settings with Listbox

    I am sorry but that doesn't make alot of sense to me. Could you please explain a little bit more?

    Thank you,
    Adam

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] My.settings with Listbox

    Have you created an application setting before? If not then I suggest that you do some reading on the subject first. If you have then just create another one but change the type to StringCollection. Now add you items in the Value field. Assuming that you have named your setting ListBoxItems you bind it to the ListBox like so:
    vb Code:
    1. myListBox.DataSource = My.Settings.ListBoxItems
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width