Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. TreeView Check Box State Problems

TreeView Check Box State Problems

Scheduled Pinned Locked Moved .NET (Core and Framework)
helpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tristan Rhodes
    wrote on last edited by
    #1

    Hi Guys, I'm having problem with getting my TreeView check boxes working as intended. I've got a set of root nodes for Groups, and all child elements belong to that group. I'm only interested in enabling check changing for child items, and changing the group check state should be prevented. I have overrided the OnBeforeCheck and OnAfterCheck to perform the desired bahviour, However, by double clicking on an unchecked check box, the check state is changed, and i get nothing in either OnDoubleClick, OnNodeDoubleClick and no Before/After check events. The OnDoubleClick and OnNodeDoubleClick are raised when going from Checked to Unchecked. Ideally i'd like to disable or hide the 'group' node check boxes Does anyone have a solution for this? Regards Tris

    ------------------------------- Carrier Bags - 21st Century Tumbleweed.

    H 1 Reply Last reply
    0
    • T Tristan Rhodes

      Hi Guys, I'm having problem with getting my TreeView check boxes working as intended. I've got a set of root nodes for Groups, and all child elements belong to that group. I'm only interested in enabling check changing for child items, and changing the group check state should be prevented. I have overrided the OnBeforeCheck and OnAfterCheck to perform the desired bahviour, However, by double clicking on an unchecked check box, the check state is changed, and i get nothing in either OnDoubleClick, OnNodeDoubleClick and no Before/After check events. The OnDoubleClick and OnNodeDoubleClick are raised when going from Checked to Unchecked. Ideally i'd like to disable or hide the 'group' node check boxes Does anyone have a solution for this? Regards Tris

      ------------------------------- Carrier Bags - 21st Century Tumbleweed.

      H Offline
      H Offline
      Henry Minute
      wrote on last edited by
      #2

      The only thing I can think of that might work is to override the two doubleclick event handlers and test for the Level of the node, passed in the eventargs, if Level == 1 (or whatever), return, otherwise do base.onWhatever. THis of course will only work if all of your 'group' nodes are at the same level. It would look something like:

      private override void OnDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
      {
      if (e.Node.Level == 1)
      {
      return;
      }

      base OnDoubleClick(sender, e);
      

      }

      Hope this helps. :)

      Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

      T 1 Reply Last reply
      0
      • H Henry Minute

        The only thing I can think of that might work is to override the two doubleclick event handlers and test for the Level of the node, passed in the eventargs, if Level == 1 (or whatever), return, otherwise do base.onWhatever. THis of course will only work if all of your 'group' nodes are at the same level. It would look something like:

        private override void OnDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
        if (e.Node.Level == 1)
        {
        return;
        }

        base OnDoubleClick(sender, e);
        

        }

        Hope this helps. :)

        Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

        T Offline
        T Offline
        Tristan Rhodes
        wrote on last edited by
        #3

        Hi Henry, Thanks for the reply, but i've tried overriding the OnDoubleClick and OnNodeDoubleClick and neither of them are called when double clicking a node, except when going from checked to unchecked. I will see if i can make it reproducable and submit a project to MS. Regards Tris

        ------------------------------- Carrier Bags - 21st Century Tumbleweed.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups