We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Hierarchial TreeviewAdv node selection

Hi,
Is it possible to have a hierarchical selection in the tree with check options as shown below. If the user selects A then if B is selected previously it should be unselected. This can be done by setting the SelectionMode property to single. Similarly When child nodes if A2 is Selected then all the selected items of the other child A1 should be unselected including parent B and its children should be unselected. But the level 3 child nodes can be multi-selected.
How to achieve this using TreeViewAdv?

A
A1
a1
a2
A2
a1
a2
B
B1
b1
b2
B2
b1
b2

Thanks in advance

1 Reply

FS Fathima Shalini P Syncfusion Team June 12, 2009 10:24 AM UTC

Hi Nitroxn,

Thank you for your interest in Syncfusion Products.

We can perform multiple selection in the sub nodes and single selection in the parent nodes in the TreeviewAdv's click event. Kindly refer to the code snippet and the sample given below that illustrates this


private void treeViewAdv1_Click(object sender, EventArgs e)
{
Point controlPoint = this.treeViewAdv1.PointToClient(Control.MousePosition);
TreeNodeAdv node = this.treeViewAdv1.GetNodeAtPoint(controlPoint);
if (node != null)
{
if (node.Level == 3)
{
this.treeViewAdv1.SelectionMode = TreeSelectionMode.MultiSelectSameLevel;
}
else
{
for(int i=0;i {
if (this.treeViewAdv1.SelectedNodes[i].Level == 3)
{
this.treeViewAdv1.SelectedNodes.Clear();
this.treeViewAdv1.SelectedNodes.Add(node);
}
}
this.treeViewAdv1.SelectionMode = TreeSelectionMode.Single;
}
}
}


http://files.syncfusion.com/support/Tools.Windows/7.2.0.20/F82390/main.htm

Please let me know if any concerns.

Regards,
Fathima

Loader.
Live Chat Icon For mobile
Up arrow icon