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. C#
  4. Disable Checkboxes for Treeview Node

Disable Checkboxes for Treeview Node

Scheduled Pinned Locked Moved C#
help
2 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.
  • C Offline
    C Offline
    Cracked Down
    wrote on last edited by
    #1

    Hi all, I am looking for code which could help me to disable checkbox for treenode, I had look at Threestate checkboxes article shared on CP, however I want to display Image for Treenode as well, so cant use that code(Threestate checkboxes are displayed as images in that article code). If anybody help me to achieve this that would be very appreciable. Thanks in advance

    L 1 Reply Last reply
    0
    • C Cracked Down

      Hi all, I am looking for code which could help me to disable checkbox for treenode, I had look at Threestate checkboxes article shared on CP, however I want to display Image for Treenode as well, so cant use that code(Threestate checkboxes are displayed as images in that article code). If anybody help me to achieve this that would be very appreciable. Thanks in advance

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I have a code for the same.

      this.tree.DrawMode = TreeViewDrawMode.OwnerDrawText;
      this.tree.DrawNode += new DrawTreeNodeEventHandler(tree_DrawNode);

      void tree_DrawNode(object sender, DrawTreeNodeEventArgs e)
      {
      if (e.Node.Level == 1)
      HideCheckBox(e.Node);
      e.DrawDefault = true;
      }

      private void HideCheckBox(TreeNode node)
      {
      TVITEM tvi = new TVITEM();
      tvi.hItem = node.Handle;
      tvi.mask = TVIF_STATE;
      tvi.stateMask = TVIS_STATEIMAGEMASK;
      tvi.state = 0;
      IntPtr lparam = Marshal.AllocHGlobal(Marshal.SizeOf(tvi));
      Marshal.StructureToPtr(tvi, lparam, false);
      SendMessage(this.tree.Handle, TVM_SETITEM, IntPtr.Zero, lparam);
      }

      HTH

      Jinal Desai - LIVE Experience is mother of sage....

      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