• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 658
  • Last Modified:

Items NOT Checked - Hard question

In my attaced code my label is getting populated with items that have been checked in the RadList.

I need a second label to be populated with the items that WERE NOT checked.
Private Shared Sub getFIPS(ByVal listBox As RadListBox, ByVal label As Label)
        Dim sb As New StringBuilder()
        Dim collection As IList(Of RadListBoxItem) = listBox.CheckedItems
        For Each item As RadListBoxItem In collection
            sb.Append(item.Value & ",")
        Next
        label.Text = sb.ToString().Substring(0, sb.ToString().Length - 1)
    End Sub

Open in new window

0
lrbrister
Asked:
lrbrister
  • 6
  • 2
1 Solution
 
13598Commented:
Loop through the items collection and check if checked = false.
0
 
13598Commented:
Or maybe you could used a derived class so you can use it like you use checkeditems.
Something like this:
public class CheckedListBoxEx:CheckedListBox  
    {  
        public CheckedListBoxEx(): base()              
        { }  
 
        public UncheckedItemCollection UncheckedItems  
        {  
            get  
            {  
                UncheckedItemCollection tmpColl = new UncheckedItemCollection();  
 
                for (int i = 0; i < base.Items.Count; i++)  
                {  
                    if (!base.GetItemChecked(i))  
                        tmpColl.Add(base.Items[i]);  
                }  
                return tmpColl;  
            }  
        }  
 
    }  
 
    public class UncheckedItemCollection:ObjectCollection  
    {  
        public UncheckedItemCollection()  
        { }      
    }  
 
    public class ObjectCollection : List<object>  
    { }  

0
 
13598Commented:
Derived class in vb.net:
Public Class CheckedListBoxEx
      Inherits CheckedListBox
            Public Sub New()
                  MyBase.New()
            End Sub

            Public ReadOnly Property UncheckedItems() As UncheckedItemCollection
                  Get
                        Dim tmpColl As New UncheckedItemCollection()

                        For i As Integer = 0 To MyBase.Items.Count - 1
                              If Not MyBase.GetItemChecked(i) Then
                                    tmpColl.Add(MyBase.Items(i))
                              End If
                        Next i
                        Return tmpColl
                  End Get
            End Property

End Class

      Public Class UncheckedItemCollection
            Inherits ObjectCollection
            Public Sub New()
            End Sub
      End Class

      Public Class ObjectCollection
            Inherits List(Of Object)
      End Class
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
lrbristerAuthor Commented:
13598:
This is not a checkbox list.  This is a Telerik RadList with checkboxes on
<telerik:RadListBox ID="RadListBox1" runat="server" CheckBoxes="true" Height="290px" Width="200px">
 </telerik:RadListBox>
0
 
13598Commented:
Can't you just loop through the items collection and check state It not checked use it?
0
 
lrbristerAuthor Commented:
There doesn;t seem to be a Not Is checked method I can use...
0
 
13598Commented:
There is no checked property for the item?
0
 
13598Commented:
It would be something like:
 Dim collection As IList(Of RadListBoxItem) = listBox.items
        For Each item As RadListBoxItem In collection
if not item.checked then
            sb.Append(item.Value & ",")
end if.
        Next
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now