Tree views also can display checkboxes, much like those you can use in menu items. You can make checkboxes appear in a tree view by setting the tree view's CheckBoxes property to True. Here's how that works in the TreeViews example on the CD-ROM, when the user clicks the "Show check boxes" button:
Here's how I display which checkboxes have been checked or unchecked in that example, using the TreeNode class's Checked property:
Private Sub TreeView1_AfterCheck(ByVal sender As Object, _ ByVal e As System.Windows.Forms.TreeViewEventArgs) _ Handles TreeView1.AfterCheck If e.Node.Checked Then TextBox1.Text = "You checked: " & e.Node.Text Else TextBox1.Text = "You unchecked: " & e.Node.Text End If End Sub
You can see the results in Figure 10.12, where I've checked a node, and the program is reporting that fact in the text box.