Short of ownerdrawing the entire tree I fear not. Setting DrawMode to TreeViewDrawMode.OwnerDrawAll you can handle all the drawing yourself and just not draw the checkbox for anything but the parent. However, you also need to draw the + and - signs, any help lines and indentations.
Post by G HimangiIt is possible if you interact with the TreeView using Win32 treeview
messages TVM_*. You will need to change the 'state' of each node (see TVITEM
structure in Platform SDK).
---------
- G Himangi, Sky Software http://www.ssware.com
Shell MegaPack : GUI Controls For Drop-In Windows Explorer like Shell
Browsing Functionality For Your App (.Net & ActiveX Editions).
EZNamespaceExtensions.Net : Develop namespace extensions rapidly in .Net
EZShellExtensions.Net : Develop all shell extensions,explorer bars and BHOs
rapidly in .Net
---------
TreeViewHelper.hideCheck(treeView1, currentNode);
TreeViewHelper.cs
using System;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace SetupRevision
{
static class TreeViewHelper
{
private const int TVIF_STATE = 0x8;
private const int TVIS_STATEIMAGEMASK = 0xF000;
private const int TV_FIRST = 0x1100;
private const int TVM_SETITEM = TV_FIRST + 63;
public static void hideCheck(TreeView treeView, TreeNode node)
{
TVITEM tvItem = new TVITEM();
tvItem.hItem = node.Handle;
tvItem.mask = TVIF_STATE;
tvItem.stateMask = TVIS_STATEIMAGEMASK;
tvItem.state = 0;
IntPtr lparam = Marshal.AllocHGlobal(Marshal.SizeOf(tvItem));
Marshal.StructureToPtr(tvItem, lparam, false);
SendMessage(treeView.Handle, TVM_SETITEM, IntPtr.Zero, lparam);
}
private struct TVITEM
{
public int mask;
public IntPtr hItem;
public int state;
public int stateMask;
[MarshalAs(UnmanagedType.LPTStr)]
public String lpszText;
public int cchTextMax;
public int iImage;
public int iSelectedImage;
public int cChildren;
public IntPtr lParam;
}
[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
}
}
http://www.craigmurphy.com/blog/?p=262