JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Adding Items to Checked List Boxes

You can add items to checked list boxes much the same way you add items to standard list boxes. However, you also can add another argument to the Items.Add method call when you add items to a checked list box in code. Here's how that looks in the CheckedListBoxes example on the CD-ROM—by passing an argument of True, I'm adding a check mark to all the new checkboxes:

Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
    Dim intLoopIndex As Integer
    For intLoopIndex = 1 To 20
        CheckedListBox1.Items.Add("Item " & intLoopIndex.ToString(), True)
    Next intLoopIndex
End Sub

You can see the results of this code in the CheckedListBoxes example by clicking the "Fill list box" button, as shown in Figure 7.9.

Figure 7.9: A checked list box.
Previous Section Next Section

JavaScript Editor Free JavaScript Editor     JavaScript Editor