Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / August 2007

Tip: Looking for answers? Try searching our database.

need help with selecting/unselecting databound checkedlistbox items...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
milsnips@gmail.com - 13 Aug 2007 23:54 GMT
Hi there,

I have a checkedlistbox on my windows form which is databound to a
dataview.
If i do a "myControl.Items.Count", it returns zero, but it displays
all my items as checkbox items.

I cant figure out a way how to loop through my control and deselect/
select all when the items.count always = 0.

However, when i manually add the items, the Items.Count works okay.

Any help appreciated in how i can deselect items in a databound
checkedlistbox.
thanks,
Paul
Andrew Backer - 20 Aug 2007 22:01 GMT
Not sure why the count would be zero (I don't check it there), but I assume
it is because the items are actually coming form DataBinding and not fromthe
control's internal item list.  You could look at either your binding source
for the count, or the dataview's count property.  
Hope this helps, but we all do it a little differently:

To Clear all selected items:
   lstRecipient.SelectedItems.Clear()

To check all items you could probably use something like this:
   For Each itm As DataRowView In me.lstRecipients.Items
       lstRecipients.SetItemCheckState( lstRecipient.Items.IndexOf(itm),
CheckState.Checked
   Next

There are other ways to do this, I am sure, but I do it this way because
I have other work to do in determining who is/isn't selected (which I cut
out), so I actually make a temporary list of items.

// Andrew

> Hi there,
>
[quoted text clipped - 11 lines]
> thanks,
> Pau

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.