![]() ![]() | ||
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 CheckedListBox1.BeginUpdate() Dim intLoopIndex As Integer For intLoopIndex = 1 To 20 CheckedListBox1.Items.Add("Item " & intLoopIndex.ToString(), True) Next intLoopIndex CheckedListBox1.EndUpdate() 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.
![]() ![]() | ||