0

私は問題があります。BrightIdeasSoftware.TreeListViewWindowsフォームでツリービューを作成するために使用しています.C#WinformsアプリでこのようなMultiColumnツリービューを作成する方法も参照していますが、これを作成することに成功していません. ツリービューを作成するために私が間違っていることを教えてください。完全な説明は以下のとおりです。

  • 動的な折りたたみ可能なパネルを追加し、これにツリーを追加したい。
  • 折りたたみ可能なパネルのヘッ​​ダー id に従って、データがパネルに表示されます。
  • 親IDがあり、複数の子を持つことができます。
  • ステータス列には 1 つの画像が表示されます

以下は、ツリービューを作成するために使用している私のコードです

class Node
        {
            public string Name { get; private set; }
            public string Column1 { get; private set; }
            public string Column2 { get; private set; }

            public List<Node> Children { get; private set; }

            public Node(string name, string col1, string col2)
            {
                this.Name = name;
                this.Column1 = col1;
                this.Column2 = col2;
                this.Children = new List<Node>();
            }
        }



private void InitializeFristTabValue()
    {
        if (_UserDAC == null)
            _UserDAC = new UserDAC();
        try
        {
            DataTable dtUserGroup = _UserDAC.GetAllSECGROUPS(appDirectory, this.FindForm().Name, "InitializeFristTabValue()").Tables[0];
            CommonDataGridBind cc = new CommonDataGridBind();
            cc.GridviewGrouping(dtUserGroup, kryptonOutlookGridUserGroup, true, "GROUPID");
            DataTable SEC_Info = _UserDAC.GetSECAPPINFO(appDirectory, this.FindForm().Name, "InitializeFristTabValue()").Tables[0];
            int Location = 0;
            foreach (DataRow dtrow in SEC_Info.Rows)
            {


                int APPID;
                int.TryParse(dtrow["APPID"].ToString(), out APPID);
                collapsiblePanelobj = new CollapsiblePanel();

                if (Location == 0)
                {
                    collapsiblePanelobj.Collapse = false;
                    //collapsiblePanelobj.Dock = System.Windows.Forms.DockStyle.Fill;
                    this.collapsiblePanelobj.Size = new System.Drawing.Size(1000, 150);
                    //DataTable SEC_InfoTreeView = _UserDAC.GetAPPITEMSbyAPPID(APPID, appDirectory, this.FindForm().Name, "InitializeFristTabValue()").Tables[0];

                    // ADDNode(APPID);
                    treeListView1.Dock = System.Windows.Forms.DockStyle.Fill;
                    //_panelBox.Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Left;
                    //_panelBox.Controls.Add(treeListView1);
                    //collapsiblePanelobj.Controls.Add(_panelBox);
                    collapsiblePanelobj.Controls.Add(treeListView1);
                }
                else
                    collapsiblePanelobj.Collapse = true;
                Location = Location + 30;
                collapsiblePanelobj.Name = dtrow["APPNAME"].ToString() + dtrow["APPID"].ToString();
                collapsiblePanelobj.HeaderText = "PROGRAM: " + dtrow["APPNAME"].ToString();

                collapsiblePanelobj.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                | System.Windows.Forms.AnchorStyles.Left)
                | System.Windows.Forms.AnchorStyles.Right)));
                collapsiblePanelobj.BackColor = System.Drawing.Color.Transparent;
                collapsiblePanelobj.HeaderCornersRadius = 5;
                collapsiblePanelobj.HeaderFont = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
                collapsiblePanelobj.HeaderImage = null;
                collapsiblePanelobj.HeaderTextColor = System.Drawing.Color.Black;
                collapsiblePanelobj.Location = new System.Drawing.Point(10, Location);
                collapsiblePanelobj.RoundedCorners = true;
                //this.collapsiblePanelobj.Dock = System.Windows.Forms.DockStyle.Fill;
                this.collapsiblePanelobj.Size = new System.Drawing.Size(1000, 150);
                collapsiblePanelobj.UseAnimation = true;
                InitializeData(APPID);
                FillTree();
                AddTree();

                panel1.Controls.Add(collapsiblePanelobj);
                // GrpBoxUserGroupInfo.Controls.Add(collapsiblePanelobj);
            }
        }
        catch (Exception ex)
        {
            LogsWrite(ex, appDirectory, this.FindForm().Name, "InitializeFristTabValue()");
        }
    }

 public void ADDNode()
        {
            AddTree();

            InitializeData();
            FillTree();

        }

  private void AddTree()
        {
            treeListView1 = new BrightIdeasSoftware.TreeListView();
            treeListView1.Dock = DockStyle.Fill;
            this.Controls.Add(treeListView1);
        }

 private void InitializeData()
        {
            UserDAC _UserDAC = new UserDAC();
            DataTable SEC_InfoTreeView = _UserDAC.GetAPPITEMSbyAPPID(2, "", this.FindForm().Name, "InitializeFristTabValue()").Tables[0];
            data = new List<Node> {};
            var parent1 = new Node("User Name                         ", "State                  ", "Static Caption             ");

                for (int i = 0; i < SEC_InfoTreeView.Rows.Count; i++)
                {
                    int PrentID = Convert.ToInt32(SEC_InfoTreeView.Rows[i]["PARENTID"]);
                    if (PrentID == 0 && Convert.ToInt32(SEC_InfoTreeView.Rows[i]["INDENT"]) == 0)
                    {
                        data.Add(parent1);
                        var parentAdd = new Node(Convert.ToString(SEC_InfoTreeView.Rows[i]["USERNAME"]), "", Convert.ToString(SEC_InfoTreeView.Rows[i]["ACAPTION"]));
                        parent1 = parentAdd;
                    }
                    else if (PrentID != 0 && Convert.ToInt32(SEC_InfoTreeView.Rows[i]["INDENT"]) == 2)
                    {
                        parent1.Children.Add(new Node(Convert.ToString(SEC_InfoTreeView.Rows[i]["USERNAME"]), "", Convert.ToString(SEC_InfoTreeView.Rows[i]["ACAPTION"])));

                    }
                }

        }

 private void FillTree()
    {
       // this.treeListView.SmallImageList = imageList1;
        // set the delegate that the tree uses to know if a node is expandable   
       // treeListView1.Margin = new System.Windows.Forms.Padding(2, 1000, 2, 2);
        treeListView1.CanExpandGetter = x => (x as Node).Children.Count > 0;

        // set the delegate that the tree uses to know the children of a node
        treeListView1.ChildrenGetter = x => (x as Node).Children;

        // create the tree columns and set the delegates to print the desired object proerty
        var nameCol = new BrightIdeasSoftware.OLVColumn("User Name", "Name");
        nameCol.AspectGetter = x => (x as Node).Name;
        nameCol.Width = treeListView1.Width / 3;

        var col1 = new BrightIdeasSoftware.OLVColumn("State", "Column1");
        col1.AspectGetter = x => (x as Node).Column1;
        col1.Width = treeListView1.Width / 3;
        var col2 = new BrightIdeasSoftware.OLVColumn("Static Caption", "Column2");
        col2.AspectGetter = x => (x as Node).Column2;
        col2.Width = treeListView1.Width / 3;
        // add the columns to the tree


        treeListView1.Columns.Add(nameCol);
        treeListView1.Columns.Add(col1);
        treeListView1.Columns.Add(col2);

        // set the tree roots
        this.treeListView1.Roots = data;



    }

ここに画像の説明を入力

あなたの助けとコメントを前もって感謝します

4

0 に答える 0