以其他形式访问树视图 [英] access tree view in other form

查看:68
本文介绍了以其他形式访问树视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在c#窗口应用程序中开发软件.

我在应用程序中使用树形视图,但我在form1中定义了树形视图.

现在我想在Form2中访问此树形视图,但我无法在Form2中访问它.

我在form1中使用此代码:

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:

TreeNode[] Comportnode = treeView1.Nodes.Find(po, true);


但是我用form2编写了这段代码,如何用form2编写了此代码.


But I write this code in form2, how I can write this in form2.

推荐答案

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


为什么不向form1添加公共方法并执行所需的操作在其中:

Why don''t you add a public method to form1 and do whatever you want in it :

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



您现在可以从form2调用它.



You can now call it from form2.


这篇关于以其他形式访问树视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆