Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Hi,
 
I've checkedlistbox which is databound to a datatable.
            clbProductType.DataSource = tblProductType
            clbProductType.DisplayMember = "jdesc"
            clbProductType.ValueMember = "jmst1pk"
We can use selectedvalue to get the valuemember of the selected item.
But I need all the selectedvalues of the checkeditems.
I know looping through it and get the values. i just want to know is there any straight method like linq to achieve this?
 
PS: Kindly add checkedlistbox in tags, as I'm unable to add "CheckedListBox" in tags.
 
Thanks.
Posted 28-Jul-12 0:18am
thams1.3K
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

It's an IEnumerable, so I assume that means you can iterate over it with a line of LINQ to create a collection of objects based on it, which may then offer a 'ToArray'. Have you tried that ? If not, then, no.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

For Someone has the same question, you can try this example
 
'checkedListBox filled with a DataTable
For Each item In ckltbEmpGrupo.CheckedItems
   codEmp = item.Item("CodEmp")
next
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Dim result() as String
result = clbProductType.CheckedItems.OfType(Of DataRowView).Select(Of String)(Function(p)
         Return p.Item(clbProductType.ValueMember).ToString
End Function).Where(Function(p) p <> "0").ToArray
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.141022.2 | Last Updated 21 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100