views:

1645

answers:

1

I'm working on a treeview with its CheckBoxes property set to true. I want the same functionality as in a CheckListBox in that if I check the box of a treenode, that node will be selected; and if I select a node, that node's checkbox will be checked. I'm not sure what event I need to hookup to do this. Please help. Thanks.

+1  A: 

Try the following:

    private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
    {
        treeView1.SelectedNode.Checked = true;
    }

This event is tied to the treeviews AfterSelect event

ferrari fan
The problem with this approach is that if you keep clicking on one node, it'll only select it the very first time, and never unselect it when it's clicked again.
BFree
Then just overwrite the onclick event as well to take care of that
ferrari fan