tfowler Posted October 18, 2005 Posted October 18, 2005 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 Quote
Diesel Posted October 19, 2005 Posted October 19, 2005 Handle the BeforeCollapse event, set Cancel = true when you don't want a node to collapse Quote
tfowler Posted October 19, 2005 Author Posted October 19, 2005 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 Quote
Diesel Posted October 19, 2005 Posted October 19, 2005 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. Quote
tfowler Posted October 20, 2005 Author Posted October 20, 2005 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 Quote
tfowler Posted October 20, 2005 Author Posted October 20, 2005 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.