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 987221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:26:43+00:00 2026-05-16T05:26:43+00:00

I am in the process of migrating a VB6 app to .Net and we

  • 0

I am in the process of migrating a VB6 app to .Net and we must provide like-for-like functionality at all times. In one form is a treeview with checkboxes that has three levels of nodes. The first level serves only to group the next level down and they are not checkable. The second level nodes are checkable by the user and when checked or unchecked all its children follow suit. At all levels, clicking a node or its checkbox will mean it becomes selected, regardless of whether or not the check state is affected.

The third level is the crux of the problem (although the issue itself manifests on all treeview checkboxes): this level contains two ‘types’ of node, one which can be checked and unchecked by the user (if the parent is checked) and one type which cannot be checked or unchecked by the user regardless of the state of the parent, but its state mirrors that of its parent.

In normal use this all works as expected. However, if you quickly click one of the third level nodes (which is not supposed to be directly checkable) twice, it appears to change its check state. But if you examine the underlying value of the Checked property, it remains unaffected, so it seems it is simply a display issue. If discovered, this anomaly will be an issue for our clients as users may think they can do something that they cannot leading to expensive confusion.

I am fresh out of ideas on this one – has anyone else observed this behaviour or know about it and are there workarounds/solutions to it? I can’t help feeling I’ve missed something really obvious but after a day and a half I now have tunnel vision. Here’s some code to demonstrate the problem. Create a form with a treeview (big enough to see what’s going on) and two buttons then drop this in:

Private _node As TreeNode = Nothing


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    MessageBox.Show(_node.Text & " : " & _node.Checked.ToString)
    _node = Nothing

End Sub

Private Sub InitialiseTreeview()

    TreeView1.Nodes.Clear()

    Dim ran As New Random
    Randomize()

    For i As Int32 = 1 To 5
        Dim TLNode As New TreeNode
        Dim children As Int32 = 0

        children = ran.Next(1, 5)

        TLNode.Text = "Top Level Node " & i.ToString

        For j As Int32 = 1 To children
            TLNode.Nodes.Add("Child Node " & j.ToString)
        Next

        TreeView1.Nodes.Add(TLNode)
    Next

    TreeView1.ExpandAll()
End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    InitialiseTreeview()
End Sub


Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    InitialiseTreeview()
End Sub

Run it, and click on a node ONCE. Click Button 1 and it will tell you the node text and it’s checked state. Now click the same nodes checkbox twice, fast, observe the state of the checkmark and click button 1 again. You’ll see what I mean. Button 2 generates a fresh set of tree nodes.

  • 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-05-16T05:26:43+00:00Added an answer on May 16, 2026 at 5:26 am

    Yes, this is a bug introduced by the Vista version of the native TreeView control. When it sees the double-click event, it will automatic toggle the check state of the item. Without telling the .NET TreeView wrapper about it, the Before/AfterCheck event won’t run. This hasn’t been fixed in the .NET wrapper and probably never will.

    Working around this bug requires preventing the native control from seeing the double-click message. Add a new class to your project and paste the code shown below. Compile. Drop the new control from the top of the toolbox onto your form, replacing the existing TreeView.

    Public Class MyTreeView
        Inherits TreeView
    
        Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
            '' Filter the WM_LBUTTONDBLCLK message
            If m.Msg <> &H203 Then MyBase.WndProc(m)
        End Sub
    
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am in the process of migrating a legacy VB6 app to .Net, however
We are in the process of migrating an app to .NET 4.0 (from 3.5).
We're in process of migrating one stable project from Castle Windsor 2.5.2 to 3.0.
We are in the process of migrating our ASP.NET application to use Jquery instead
I am in the process of migrating an ASP.NET web forms application to ASP.NET
I am currently in the process of migrating a legacy app over to symfony2,
I'm in process of migrating a rails 3.0.11 app to 3.1.3. And somehow, this
We are in the process of migrating an ASP Classic/ASP.NET application from IIS 6
I'm in the process of migrating an App to the current iOS SDK. Its
I am in the process of migrating my android app from C2DM to GCM.

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.