Click here to Skip to main content
15,915,019 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I develop software in c# window application.

I am using tree view in my application but i define tree view in form1.

Now i want to access this tree view in form2 i cant't access this in form2.

I use this code in form1:
C#
TreeNode[] Comportnode = treeView1.Nodes.Find(po, true);

But I write this code in form2, how I can write this in form2.
Posted
Updated 8-Jan-12 23:05pm
v2

Hi friend make modifiers property of treeview public.
You can find modifiers property in property window.than you can able to get access of treeview
 
Share this answer
 
Comments
jaideepsinh 9-Jan-12 7:57am    
But for using this method i have to create form1 object in form2 and when i create form1 object i get error at when i another form not form1 and form2 when i create form2 object like this:
An unhandled exception of type 'System.StackOverflowException' occurred in Hart_Mon.exe
Why don't you add a public method to form1 and do whatever you want in it :

C#
public TreeNode[] Find(string key)
{
    return treeView1.Nodes.Find(key, true);
}


You can now call it from form2.
 
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