Click here to Skip to main content
15,888,055 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

I have put EventArgs it points to an error on e.Node that System.EventArgs does not contain definition for Node.

If i replace EventArgs with TreeNodeEventArgs, then that error goes away but I get an error on compilation:

Compiler Error Message: CS0123: No overload for 'TreeView2_SelectedNodeChanged' matches delegate 'System.EventHandler'

<asp:TreeView ID="TreeView2" runat="server" OnUnload="TreeViewMain_Unload"
ontreenodepopulate="TreeView2_TreeNodePopulate"
onselectednodechanged="TreeView2_SelectedNodeChanged">
<Nodes>
<asp:TreeNode PopulateOnDemand="True" Text="Machine Groups"
Value="Machine Groups"></asp:TreeNode>
</Nodes>
</asp:TreeView>
Please help me out.
Posted

1 solution

Hey there,

If you want to get the selected Node of the TreeView inside TreeView2_SelectedNodeChanged, you can do this inside the event:
C#
TreeView objTreeView = (TreeView)sender;
           if (objTreeView != null)
           {
               TreeNode selectedNode = objTreeView.SelectedNode;
               //Do something
           }


and you'll have to use System.EventArgs and this is what the event supports.

Let me know if it helps.

Azee...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900