Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I hate how the default TreeView contracts nodes that I have manually expanded. What I mean is that I expand two different parent nodes to see the child nodes. If I then click on one of the child nodes, the other parent node contracts. I don't like that. I expanded it, it should stay expanded. Is there any way to override this functionality?

 

I tried putting ExpandAll in the Click event, but then it flashes with every click...you can actually see the nodes contract and then expand back out.

 

Thanks for the help,

 

Todd

Posted

Thanks for the reply Diesel, but that doesn't work for my situation. The BeforeCollapse event is raised only when you explicitly collapse a node by clicking on the "-" symbol, or double-clicking on a node. It is not raised when the TreeView control collapses all of the expanded nodes, after I click on one of the child nodes.

 

Any other ideas?

 

Thanks,

 

Todd

Posted
I haven't been able to reproduce the sequence you describe. When I open 2 parent nodes and click on a child node, the other parent node stays expanded.
Posted

Wow...how weird. I deleted my old TreeView control and added a new one, and it works fine. I had created the original form in .NET 2002, but am now using .NET 2003. Maybe they fixed it? Oh well. In any case, it is working fine now.

 

Thanks for all of your help,

 

Todd

Posted

I figured out what is causing it

 

I slowly added back in my event handlers for the TreeView and found the handler that was causing the problem:

 

   '-------------------------------------------------------------------
   'handler for TreeView AfterSelect event - called after a node has been
   'selected in the control
   '-------------------------------------------------------------------

   Private Sub tvwTestSeq_AfterSelect(ByVal sender As System.Object, _
   ByVal e As System.Windows.Forms.TreeViewEventArgs) _
   Handles tvwTestSeq.AfterSelect
       'don't show different icon on selection
       tvwTestSeq.SelectedImageIndex = tvwTestSeq.SelectedNode.ImageIndex
   End Sub 'tvwTestSeq_AfterSelect

 

I'm doing this because I don't want the image to change when a node is selected. I want it to keep the original image. I guess I'll have to handle this differently.

 

Todd

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...