Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8342337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:44:28+00:00 2026-06-09T05:44:28+00:00

I have a TreeView in VB6, when a Node’s Image (+ or -) is

  • 0

I have a TreeView in VB6, when a Node’s Image (+ or -) is clicked the Node expands then immediately collapses, or vice versa. I have a TreeView Click method which expands/collapses a Node when it is clicked (simplified version shown below)

Private Sub MyTreeView_Click()

    Dim selectedNode As Node
    Dim nodeType As String

    Set selectedNode = MList2.SelectedItem
    If selectedNode Is Nothing Then
        Exit Sub
    End If

    nodeType = selectedNode.Key

    If nodeType = "MyNodeType" Then

        'Collapse Node if it's already expanded, otherwise expand it.
        If selectedNode .Expanded Then
            selectedNode .Expanded = False
        Else
            'Do some processing

            selectedNode .Expanded = True
        End If
    End If
End Sub

This works fine if the text part of the Node is clicked. However if the Image part of the Node is clicked the Node is expanded/collapsed before this EventHandler is reached, resulting in the Node immediately returning to its original state when it does hit this EventHandler. The first expand/collapse of the Node seems to occur on MouseDown on the Node Image.

Does anyone know how I can prevent the Node from been expanded/collapsed before hitting this EventHandler when the Node Image is clicked?

Any help would be greatly appreciated, thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T05:44:30+00:00Added an answer on June 9, 2026 at 5:44 am

    You could use the TreeView’s Collapse and Expand events to set a Boolean variable that indicates your procedure shouldn’t run. EG:

    Dim bNodeImageClicked As Boolean
    
    Private Sub MyTreeView_Collapse(ByVal Node As MSComctlLib.Node)
        bNodeImageClicked = True
    End Sub
    
    Private Sub MyTreeView_Expand(ByVal Node As MSComctlLib.Node)
        bNodeImageClicked = True
    End Sub
    
    Private Sub MyTreeView_Click()
        If bNodeImageClicked Then
            bNodeImageClicked = False
            Exit Sub
        End If
    
        'Your code...
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a treeview which contains, per node, a key and text. However, there
I have a treeView , and i want to know if some node can
I have treeview and a context menu that is shown for every node. One
I have a TreeView with a ContextMenu with Click events. When the click event
I have a treeview showing Categories and subcategories. I need to Right Click Option
I have a treeview and I wanted to add right click support for the
I have treeview and 2 imagelist first image list contains images only 42x42 and
i have a treeview in winforms . When i double click on treenode ,its
I have a TreeView with a parent node and two children node. Each of
i have treeview windows application how can i add image tooltip to treenode ..

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.