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

MultiColumnTreeView Node Selection order

Using a MultiColumnTreeView, selected nodes are not returned in the order they were selected. Order in the .SelectedNodes collection seems to always be from top to bottom *visually* in the control.

Is it possible to obtain the list of selected nodes in the *order that the user selected them*?

Using Syncfusion Essential Studio 2008 Vol2 v6.3.0.6.

1 Reply

FS Fathima Shalini P Syncfusion Team June 11, 2009 08:57 AM UTC

Hi Sam,

Thank you for your interest in Syncfusion Products.

To get the SelectedNodes in the order they were selected, we need to keep track the selected TreeNodeAdvs and store it in a collecton. Kindly refer to the code snippet and the sample provided below that illustrates this:


private void multiColumnTreeView1_Click(object sender, EventArgs e)
{
bool flag = true, flag1 = false;
Point controlPoint = this.multiColumnTreeView1.PointToClient(Control.MousePosition);
TreeNodeAdv node = this.multiColumnTreeView1.GetNodeAtPoint(controlPoint);
//Remove the TreeNodeAdv from the collection when unselecting the TreeNodeAdv
for(int i = TreeCollection.Count-1 ; i>=0 ; i--)
{
if(node.Text == TreeCollection[i].Text)
{
TreeCollection.RemoveAt(i);
flag = false;
}
}
// Remove the previously selected Nodes when single select is done
for (int i = TreeCollection.Count - 1; i >= 0; i--)
{
flag1 = false;
foreach (TreeNodeAdv tree in this.multiColumnTreeView1.SelectedNodes)
{
if (tree.Text == TreeCollection[i].Text)
{
flag1 = true;
}
}
if (!flag1)
{
TreeCollection.RemoveAt(i);
}
}
if(flag)
{
TreeCollection.Add(node);
}
}


http://files.syncfusion.com/support/Tools.Windows/6.3.0.6/F82374/main.htm

Please let me know if any concerns.

Regards,
Fathima

Loader.
Live Chat Icon For mobile
Up arrow icon