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

button or clickable pic in the node of TreeView

How can we associate a button or other control or something like clickable icon with the node of tree? We need to show our "open dialog" which will add the nodes to the tree, when user will click such button. The click on the node will select the node, the doubleclick will expand the node, so we need some clickable area associated with the node.

2 Replies

AD Administrator Syncfusion Team September 26, 2005 04:39 PM UTC

I can say in addition, that we also need buttons near some nodes to save the nodes content. So the implicit ways of user interaction with the node, like doubleclick on the node, will not be siutable for the user. The clickable right and left icons of the node seems the best way, but how can we catch an event of icon click?


VS Vijayanand S Syncfusion Team September 27, 2005 09:53 AM UTC

Hi Eugene, You could use the Left Image and Right Image of a node as a clickable area to use it as a button associated with that particular tree node. Following is the code snippet that illustrates this: private void treeViewAdv1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { Point clickpt = new Point(e.X, e.Y); TreeNodeAdv node = this.treeViewAdv1.PointToNode( clickpt ); string aText; aText = node.Text; //To check whether mouse clicking on the left image. 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 (imgrec.Contains(clickpt)== true) { Console.WriteLine("Clicked on " + node.Text + "''''s left image"); } //To check whether the mouse clicking on the RightImage point. Point imgpt1 = new Point (node.RightImagesX,node.TextBounds.Y); Size imgSize1 = new Size(this.imageList2.ImageSize.Width, this.imageList2.ImageSize.Height); Rectangle imgrec1 = new Rectangle(imgpt1, imgSize1); if (imgrec1.Contains(clickpt)== true) { Console.WriteLine("Clicked on " + node.Text + "''''s right image"); } } Please take a look at the attached sample and let me know if this meets your requirement. If not, please provide more details regarding this issue and modify the attached sample and send it over to me. Thanks for using Syncfusion products. Regards, Vijay TreeViewAdv

Loader.
Live Chat Icon For mobile
Up arrow icon