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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

TreeViewAdv AfterSelct Event

Thread ID:





91126 Nov 4,2009 11:15 PM UTC Nov 5,2009 03:37 PM UTC WinForms 1
Tags: Tools
Louis Sicard
Asked On November 4, 2009 11:15 PM UTC


I've noticed that the TreeViewAdv AfterSelect event is thrown regardless of where the user has clicked (on a node or not)... Is there anyway to prevent the event to be thrown when the user hasn't actually clicked on a node?

Thanks in advance



Rajasekar B [Syncfusion]
Replied On November 5, 2009 03:37 PM UTC

Hi Louis,

You need to get the location of the mouse and then check whether the location is within the node. if not, cancel the BeforeSelect event. It will cancel the AfterSelect event also.

Below is the sample code:

private void treeViewAdv1_BeforeSelect(object sender, TreeViewAdvCancelableSelectionEventArgs args)
Point p = Control.MousePosition;
Point p1 = this.treeViewAdv1.PointToClient(p);
treeNode = this.treeViewAdv1.GetNodeAtPoint(p1, true);
if (treeNode != null)
if (FindTreeNode(treeNode.Nodes))
args.Cancel = false;
args.Cancel = true;

bool FindTreeNode(TreeNodeAdvCollection treeNodeCol)
bool nodePresent = false;
foreach (TreeNodeAdv treeNod in treeNodeCol)
if (treeNod == treeNode)
nodePresent = true;
if (treeNod.HasChildren)
return nodePresent;

I have attached the sample.
Let me know if you have any questions.




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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

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