DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Mon, 13 Aug 2007 15:54:23 -0700,    posted on: microsoft.public.dotnet.framework.windowsforms.databinding        back       

Thread Index
  1    unknown
          2    Andrew Backer


need help with selecting/unselecting databound checkedlistbox items...   
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
Date:Mon, 13 Aug 2007 15:54:23 -0700   Author:  

Re: need help with selecting/unselecting databound checkedlistbox items...   
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,
> 
> 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
Date:Mon, 20 Aug 2007 21:01:03 +0000 (UTC)   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us