Larry Brister
asked on
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.
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
Loop through the items collection and check if checked = false.
Or maybe you could used a derived class so you can use it like you use checkeditems.
Something like this:
public class CheckedListBoxEx:CheckedLi stBox
{
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:Ob jectCollec tion
{
public UncheckedItemCollection()
{ }
}
public class ObjectCollection : List<object>
{ }
Something like this:
public class CheckedListBoxEx:CheckedLi
{
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:Ob
{
public UncheckedItemCollection()
{ }
}
public class ObjectCollection : List<object>
{ }
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
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
ASKER
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>
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>
Can't you just loop through the items collection and check state It not checked use it?
ASKER
There doesn;t seem to be a Not Is checked method I can use...
There is no checked property for the item?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.