Windows Develop Bookmark and Share   
 index > Windows Forms General > Hiding checkbox for childnode in Windows Form Treeview control
 

Hiding checkbox for childnode in Windows Form Treeview control

Hi!

How do I hide checkbox for the childnodesof a treeview control? There is no property for the TreeNode to disable the checkbox once TreeView.CheckBoxes is set to true.

Vivekananda  Wednesday, May 09, 2007 11:22 AM

Hi,

There is no build-in support, you have to p/invoke Win32 API to send TVM_SETITEM with TVIS_STATEIMAGEMASK flag. Seethis sample code below by Jeffery:

http://groups.google.com/group/microsoft.public.dotnet.framework.windowsforms/msg/69a62ef36dcd8eb8

Best Regards.

Gavin Jin - MSFT  Monday, May 14, 2007 8:42 AM
You can't, TreeView doesn't support it. Best you can do is include an empty icon in the ImageList...
nobugz  Thursday, May 10, 2007 12:13 AM

Hi!

But, I want the checkbox available for rootnodes. I have a 2 Level Treeview. The Level1 Nodes should have the Checkbox. If you were also referring for the same can you guide me in applying empty icon for the childnodes?

Vivekananda  Thursday, May 10, 2007 4:31 AM

Hi,

I have same requirement.

Adding empty icon will display ICON, it is not hiding checkbox.

Is there any way I can hide checkbox for any particular node?

thanks

ST_SHIR  Thursday, May 10, 2007 10:12 PM

Hi,

There is no build-in support, you have to p/invoke Win32 API to send TVM_SETITEM with TVIS_STATEIMAGEMASK flag. Seethis sample code below by Jeffery:

http://groups.google.com/group/microsoft.public.dotnet.framework.windowsforms/msg/69a62ef36dcd8eb8

Best Regards.

Gavin Jin - MSFT  Monday, May 14, 2007 8:42 AM

Sweet! Gavin, thanks for finding that. That approach is much better than owner-drawing the whole thing to hidecheckboxes.

MuscleHead  Tuesday, February 19, 2008 3:23 AM

Just a tip for someone who will use Jeffrey Tan solution:

The checkbox is showing again when TreeNode check box is checked (by pressing space when TreeNode has focus, for example).

bsivanov  Thursday, October 02, 2008 2:15 PM

I found that too, but in my case, I was able to work around it by setting the .tag property of the nodes I wanted to supress the checkbox to "Hide". Then in the BeforeCheck event of the treeview, I look for the tag and cancel if it is "Hide".
Nyc-mb  Tuesday, December 09, 2008 3:06 PM

You can use google to search for other answers

Custom Search

More Threads

• MenuStrip in C# 2005
• Make a form on top of all windows...
• Clipboard structure
• Obtaining File Icons on Windows Vista
• working with 2 forms
• What is equivalent function of RichTextBox Span() function of VB6.0 in VB.NET
• Invalid Namespace Exception with My.Computer.Info.OSFullName
• Sliding Toolbox tabs
• Click on "ok" in another application
• Bill-Of_Lading sample code in VB.Net or C#