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 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  
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  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 840
1 OriginalGriff 437
2 Abhinav S 303
3 thatraja 215
4 Emre Ataseven 200
0 Sergey Alexandrovich Kryukov 8,122
1 OriginalGriff 4,520
2 Peter Leow 3,744
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107


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