How do I remove the check boxes of the root nodes marked in the control given below?
This is what I have done so far.
private void SetRootNode(TreeNode node, int index)
{
IntPtr pt = treeViewFactMaps.Handle;
TvItem tvi = new TvItem();
tvi.hItem = node.Handle;
tvi.mask = TvifState;
tvi.stateMask = TvisStateimagemask;
tvi.state = index << 12;
SendMessage(node.TreeView.Handle, TvmSetitem, IntPtr.Zero,ref tvi);
}
The above method is called in a method called "InitializeFactMaps()".
treeViewFactMaps.Nodes.Clear();
bool selectFirstNode = true;
TreeNode firstNode = null;
foreach (DataSource ds in Sample.DataSources)
{
TreeNode root = treeViewFactMaps.Nodes.Add(ds.ItemName);
if (selectFirstNode)
{
firstNode= root;
selectFirstNode = false;
}
SetImage(root, false, false);
SetRootNode(root, 0);
foreach (DataSource childSource in ds.Children)
{
TreeNode leaf = root.Nodes.Add(childSource.ItemName);
leaf.Checked = Sample.UsedFactMaps.ContainsKey(childSource.FactId);
leaf.Tag = childSource.FactId;
SetImage(leaf, false, true);
}
}
treeViewFactMaps.CollapseAll();
treeViewFactMaps.Sort();
treeViewFactMaps.SelectedNode = firstNode;
Please note that I only want the check boxes of the root nodes to be removed. Not the child nodes.
I have used the solution posted for a similar question in Stack Overflow which can be found at TreeView Remove CheckBox by some Nodes, but it didn't work for me.