本文介绍了复选框在动态树视图中选中了控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有两个桌子

Hi,

I have two table

ParentTable
Data

ParentID ParentName
   1         John
   2         Chris


另一张桌子


Another Table

ChildTable
Data
ChildID ParentID ChildName   active
    1          1        aaa       1
    2          1        bbb       0
    3          2        ccc       1
    4          2        ddd       0


现在,我想在动态树视图中显示它
这是我的动态树.


Now I want to show it in dynamic tree view
this is my dynamic tree.

TreeView myTreeView = new TreeView();
myTreeView.Location = new Point(100, 100);
myTreeView.CheckBoxes = true;
myTreeView.Size = new Size(200, 200);
this.Controls.Add(myTreeView);


void BuildingTree()
       {

           DataSet PrSet = "Select * from ParentTable";

           myTreeView.Nodes.Clear();

           foreach (DataRow dr in PrSet.Tables[0].Rows)
           {

               TreeNode tnParent = new TreeNode();

               tnParent.Text = dr["ParentName"].ToString();

               tnParent.Tag= dr["ParentID"].ToString();

               tnParent.Expand();

               myTreeView.Nodes.Add(tnParent);

               FillChild(tnParent,convert.toIn32(tnParent.Tag));

           }



       }
       public void FillChild(TreeNode parent, int ParentId)
       {

           DataSet ds = PDataset("Select * from ChildTable where ParentId =" + ParentId");

            foreach (DataRow dr in ds.Tables[0].Rows)
           {

               TreeNode child = new TreeNode();

               child.Text = dr["ChildName"].ToString().Trim();

               child.Tag= dr["ChildID"].ToString().Trim();

               parent.Add(child);

           }

       }


这是基于桌面的应用程序.我需要在active = 1时选中复选框.
我是新手开发人员,
请帮帮我.
Masud


It is desktop based application.I need to show check Box checked when active=1.
I am a novice developer,
Please help me.
Masud

推荐答案


这篇关于复选框在动态树视图中选中了控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 23:21