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

Treeview - (single and multi column) Ignore auto-expand on double-click

When you double-click a node with children, it expands/collapses before the double-click event is fired so I can find no way to cancel the expand. Is there a property/method I can use to turn off the double-click to expand node, I only want to expand using the +/- images.

5 Replies

NR Nandakumar R Syncfusion Team January 15, 2010 11:36 AM UTC

Hi,

Please refer to the following code and sample for how this can be done.

[C#]
void treeViewAdv1_BeforeExpand(object sender, Syncfusion.Windows.Forms.Tools.TreeViewAdvCancelableNodeEventArgs e)
{
Point p = this.treeViewAdv1.PointToClient(Control.MousePosition);
TreeNodeAdv node = this.treeViewAdv1.GetNodeAtPoint(p, true);
if (node != null)
{
if (node.TextBounds.Contains(p))
{
e.Cancel = true;
}
}
}

void treeViewAdv1_BeforeCollapse(object sender, Syncfusion.Windows.Forms.Tools.TreeViewAdvCancelableNodeEventArgs e)
{
Point p = this.treeViewAdv1.PointToClient(Control.MousePosition);
TreeNodeAdv node = this.treeViewAdv1.GetNodeAtPoint(p, true);
if (node != null)
{
if (node.TextBounds.Contains(p))
{
e.Cancel = true;
}
}
}


[Sample]
http://www.syncfusion.com/uploads/redirect.aspx?file=TreeViewExpandCollapse_f61f7657.zip&team=support

Please try this and let me know if this helps.

Regards,
Nanda


AD Administrator Syncfusion Team January 15, 2010 12:01 PM UTC

Thanks for the info, can you add this as a future enhancement please.


NR Nandakumar R Syncfusion Team January 15, 2010 12:04 PM UTC

Hi,

Thanks for the update.

This has already been added as a KB and users can use this option to work with this behaviour. We do not have any feature implementation for this in future as the existing behaviour is considered to be the standard behaviour for Syncfusion TreeViewAdv.

Regards,
Nanda


AD Administrator Syncfusion Team January 15, 2010 01:59 PM UTC

It may be the standard implementation that many users require, but surely adding this as a feature will give your users more options.

Furthermore, your code sample doesn't actually work if you double-click the icon, just the text, but this is not a problem for me.


GS Githanjali S Syncfusion Team January 20, 2010 12:57 PM UTC

Hi James,

The below code will ensure that the node will expand only when clicked on the Node's Expandable button ( that is, the "+" box on the left of the node) and not when clicked either on the image or text associated with the node:


TreeNodeAdv node = this.treeViewAdv1.SelectedNode;
//Get the mouse positions.
Point p = this.treeViewAdv1.PointToClient(Control.MousePosition);

//Make the Left Image as the clickable object using the Rectangle
Point imgpt = new Point(node.TextAndImageBounds.X, node.TextAndImageBounds.Y);
Size imgSize = new Size(this.imageList1.ImageSize.Width, this.imageList1.ImageSize.Height);
Rectangle imgrec = new Rectangle(imgpt, imgSize);

if (node != null)
{
if (imgrec.Contains(p)||node.TextBounds.Contains(p))
{
e.Cancel = true;
}
else
{
e.Cancel = false;
}
}



Regards,
Githanjali

Loader.
Live Chat Icon For mobile
Up arrow icon