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