树视图:单击后加载节点 [英] Tree view : load nodes after click on it

查看:56
本文介绍了树视图:单击后加载节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi Dears

我在SQL Server中有一个名为"EQU"的表。 ,基于它我在C#表单上创建了一个树视图,由于数据量很大,加载速度很慢....

I have a table in SQL Server with name "EQU" , Base on it i created a tree view on C# form , Because of large amount of data , it will very slow to loading ....

我认为最好的方法是加载子节点用户扩展其中一个但我不知道如何。

I think best way is , loading sub nodes after user expand one of them but i don't know how.

是否有人帮助我......?

is any one help me ...?

我的表名是:   EQU

My table Name is : EQU

儿童代码为:  EQUID

Child Code is : EQUID

父代码为:  PEQUID

Parent Code is : PEQUID

设备名称:  EQUNO

Equipment Name : EQUNO

EQU的描述是:  DESEQU

Description of EQU is : DESEQU




级别字段为:  NIV" For Restrict Tree view"

Level Field is : NIV "For Restrict Tree view"

订单字段为:  ORD  "对于排序子节点"

Order Field is : ORD  "For Sort Sub Nodes"

// --------------------------我使用的代码:

//-------------------------- Code I used :

  public void CreateTreeView(TreeNodeCollection parentNode,int parentID,DataTable mytab)

        {

$
            foreach(mytab.Rows中的DataRow dta)

            {

                if(Convert.ToInt32(dta [" PEQUID"])== parentID)

                {

                    String key = dta [" EQUID"]。ToString();

                    String text = dta [" EQUNO"]。ToString()+" - (" + dta [" DESEQU"]。ToString()+")" ;;

                    TreeNodeCollection newParentNode = parentNode.Add(key,text).Nodes;

                    CreateTreeView(newParentNode,Convert.ToInt32(dta [" EQUID"]),mytab);

                }¥b $ b            }¥b $ b        }

  public void CreateTreeView(TreeNodeCollection parentNode, int parentID, DataTable mytab)
        {

            foreach (DataRow dta in mytab.Rows)
            {
                if (Convert.ToInt32(dta["PEQUID"]) == parentID)
                {
                    String key = dta["EQUID"].ToString();
                    String text = dta["EQUNO"].ToString() + "-(" + dta["DESEQU"].ToString() + ")";
                    TreeNodeCollection newParentNode = parentNode.Add(key, text).Nodes;
                    CreateTreeView(newParentNode, Convert.ToInt32(dta["EQUID"]), mytab);
                }
            }
        }

谢谢之前

Farzad Khajeh

Farzad Khajeh




推荐答案

Hello farzad,

Hello farzad,

在createTreeView方法中,使用递归循环将节点添加到treeview中,I不能假设你根据什么算法添加节点。如果你给我一个表数据的屏幕截图那就太好了。  至于如何创建一个
响应程序。我建议你使用多线程技术。连接数据库的操作是一项耗时的操作。使用任务对象将提供高效且响应迅速的程序。并且treeview控件提供AfterExpand事件,当节点消耗时将发生
。你可以从那里加载子节点。

In your createTreeView method you use recursive loop to add nodes into treeview, I can't assume you add nodes based on what algorithm. It would be nice if you give me the screen shot of your table data.  As for how to create a responsive program. I suggest you use multi thread technology. The action of connecting database is a time-consuming operation. Use task object will provided efficient and responsive program. and the treeview control provide AfterExpand event, which will occurs when a node has been expend. you could loading child nodes from there.

祝你好运,

Neil Hu


这篇关于树视图:单击后加载节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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