Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Treeview problem

Status
Not open for further replies.

myrgir

Programmer
Feb 7, 2006
62
CA
Hi
I have a tree view with checkboxes in it. For each parent node I have a combo box associated to it. And below each parent node I have child node that represent what choice we have in the combo box associated to the parent node.

Now when I click on a node child I put the node that the user just click on to the selectednode.
so I do this:
Code:
Private Sub TreeView1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TreeView1.MouseDown
     TreeView1.SelectedNode = TreeView1.GetNodeAt(e.X, e.Y) 
End Sub

When I click on the Text of the Child node it's ok, but when I want to click on the checkbox beside it, it doesn't check the checkbox.

I found where is my problem but I don't understand why it does this.
So this is the code that I have in the TreeView1_AfterSelect event. I put the line where it cause this problem with *** before.
Code:
For Each TP In TabControl1.TabPages
  For Each c In TabControl1.TabPages(idx).Controls
     If TypeOf c Is ComboBox Then
        If c.valuemember = NodeParentId Then
            ***c.Text = NodeText
            found = 1
            Exit Sub
         End If
      End If
   Next
   idx = idx + 1
Next

Thanks in advance
 
I think that maybe my problem come from this line
TreeView1.SelectedNode = TreeView1.GetNodeAt(e.X, e.Y)

but I don,t know why.
can anyone already use it with a treeview with checkboxes in it?
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top