[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Synchronising an arraylist with a checkedlistbox

Posted on 2010-11-20
4
Medium Priority
?
543 Views
Last Modified: 2012-05-10
I am using an ArrayList in one of my classes to hold a collection of "People" objects. I am also using a CheckedListBox component on a form to present this collection of people on screen.

I have a button which adds a new person (from a set of input TextBoxes) to both the ArrayList and the CheckedListBox at the same time so as to keep them in synch.

My question -
Is there any way I can set the collection in the CheckedListBox to be the same as that in the ArrayList so that the two are automatically kept in synch?
0
Comment
Question by:Jedeye
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34179674
I think you are already using the best approach. There are other more complicated approaches but this one is the simplest
0
 
LVL 13

Expert Comment

by:Corey Scheich
ID: 34181952
If you use a bindinglist instead of an arraylist you can set the bindinglist as the datasource of the checkedlistbox.  Then you can add directly to the bindinglist only and the checkedlistbox should update automatically.  Arraylists won't work the same because they don't raise listChanged events
0
 

Author Comment

by:Jedeye
ID: 34182692
Hi Corey2
Your solution sounds as though it would be perfect - but I can't find any obvious way to add the bindinglist as the datasource of the checkedlistbox - I am probably missiing something - can you enlighten me?
0
 
LVL 13

Accepted Solution

by:
Corey Scheich earned 2000 total points
ID: 34184004
You simply set the datasource property of the Checkedlistbox to your bindinglist. If your bindinglist is filled with a more complex object you may need to use the DisplayMember and ValueMember properties to have more control over the behavior


Dim BL as new bindinglist (of String)
Checkedlistbox1.datasource = bl

bl.add("One Fish")
bl.add ("Two Fish")
bl.add ("Red Fish")
bl.add ("Blue Fish")

Open in new window

0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Introduction to Processes
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question