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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

92422 Jan 14,2010 10:31 AM UTC Jan 20,2010 12:57 PM UTC Windows Forms 5
loading
Tags: Tools
Administrator [Syncfusion]
Asked On January 14, 2010 10:31 AM UTC

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.

Nandakumar R [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On January 15, 2010 12:01 PM UTC

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

Nandakumar R [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On 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.

Githanjali S [Syncfusion]
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;