PDA

Click to See Complete Forum and Search --> : Need help in treeview


Jigna
Feb 3rd, 2007, 11:20 AM
Hello there......

I am using ASP.NET and C#.NET and want to perform action on right clicking on a node in treeview.I dont know even the event or property which might help me in perfoming this.How to perform action on right click?
I have searched a lot.....but i got the articals that tells about windows form and i want that in WEB FORM.
Please help me to solve this.

Thank you in Advance

Jigs

AIS4U
Feb 10th, 2007, 01:43 AM
Jigna:

I am not sure if this is what you are looking for or not.

The following example displays the ContextMenu assigned to
a TreeView when the right mouse button is clicked and released.

This code assumes you have a Form with a TreeView on it. It
is also assumed that the TreeView has a ContextMenu assigned
to its ContextMenu property.

[C#]
private void treeView1_MouseUp(object sender, MouseEventArgs e)
{
// If the right mouse button was clicked and released,
// display the context menu assigned to the TreeView.
if(e.Button == MouseButtons.Right)
{
treeView1.ContextMenu.Show(treeView1, new Point(e.X, e.Y) );
}
}

Also, I am not 100% certain, but I think that the mouse pointer must be over a child node and not a parent node.

Good Luck

jmcilhinney
Feb 10th, 2007, 08:09 AM
I'm guessing that AIS4U's code is for the WinForms TreeView, not the WebForms version.

AIS4U
Feb 10th, 2007, 08:02 PM
Yup, you are right.

didn't notice the Web forms part of the request.

sorry about that.

You can find the Web Forms TreeView Code here:
http://www.codeproject.com/aspnet/ExtendedTreeView.asp