Checked and Unchecked Items?

TheNewKid

New member
Joined
Oct 27, 2008
Messages
1
Programming Experience
Beginner
Hi All...

I have a scenario which needs to be resolved.
I have One ListedBox which is populated with Items. using StreamReader to read from a Textfile.
I also have two Textboxes which i need to populate, once the user clicks a Button.

On "onClick" any item which is checked or unchecked will populate the TextBox
CheckedTextBox or UncheckedTextBox.


My code thus far only lets me display checked items in the CheckedTextBox, and the unchecked items still do not populate the UncheckedTextBox.
VB.NET:
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim ItemChecked As CheckedListBox.CheckedItems

        For Each ItemChecked In CheckedListBox.CheckedItems
        CheckedTextBox.AppendText(ItemChecked.ToString() & vbCrLf)
        Next
        UnCheckedTextBox.AppendText(ItemChecked.ToString() & vbCrLf)
How would i overcome this?

I did also try:
VB.NET:
        If ItemChecked = True Then
            CheckedTextBox.AppendText(ItemChecked.ToString() & vbCrLf)
        Else
            UncheckedTextBox.AppendText(ItemChecked.ToString() & vbCrLf)[COLOR="Lime"] ' edit this line but how?
        End If[/COLOR]
            End Sub
Many Thanks
TheNewKid
 
VB.NET:
		For i As Integer = 0 To Me.CheckedListBox1.Items.Count - 1
			If Me.CheckedListBox1.GetItemCheckState(i) = CheckState.Checked Then
				Me.TextBox1.AppendText(Me.CheckedListBox1.Items(i).ToString() & ControlChars.NewLine)
			Else
				Me.TextBox2.AppendText(Me.CheckedListBox1.Items(i).ToString() & ControlChars.NewLine)
			End If
		Next
 
Back
Top