title: how to create multiple column tree view with image
body: <p>i have a problem. i am using the <code>BrightIdeasSoftware.TreeListView</code> to create treeview in my windows form and i also take the reference of <a href="https://stackoverflow.com/questions/9802724/how-to-create-a-multicolumn-treeview-like-this-in-c-sharp-winforms-app">How to create a MultiColumn treeview like this in C# Winforms app</a> but i am not success to create this. Can you please tell me what i am doing mistake to create the treeview. The complete description is below.  </p>
  
  <ul>
  <li>i want to add the dynamic collapsible Panel and into this want to add tree in this. </li>
  <li>The data will display into the panel according the collapsible panel header id . </li>
  <li>i have a parent id and that can have multiple child.</li>
  <li>Status Column will display one image </li>
  </ul>
  
  <p>below is my code that i am using to create the treeview </p>
  
  <pre><code>class Node
          {
              public string Name { get; private set; }
              public string Column1 { get; private set; }
              public string Column2 { get; private set; }
  
              public List&lt;Node&gt; 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&lt;Node&gt;();
              }
          }
  
  
  
  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&lt;Node&gt; {};
              var parent1 = new Node("User Name                         ", "State                  ", "Static Caption             ");
  
                  for (int i = 0; i &lt; SEC_InfoTreeView.Rows.Count; i++)
                  {
                      int PrentID = Convert.ToInt32(SEC_InfoTreeView.Rows[i]["PARENTID"]);
                      if (PrentID == 0 &amp;&amp; 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 &amp;&amp; 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 =&gt; (x as Node).Children.Count &gt; 0;
  
          // set the delegate that the tree uses to know the children of a node
          treeListView1.ChildrenGetter = x =&gt; (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 =&gt; (x as Node).Name;
          nameCol.Width = treeListView1.Width / 3;
  
          var col1 = new BrightIdeasSoftware.OLVColumn("State", "Column1");
          col1.AspectGetter = x =&gt; (x as Node).Column1;
          col1.Width = treeListView1.Width / 3;
          var col2 = new BrightIdeasSoftware.OLVColumn("Static Caption", "Column2");
          col2.AspectGetter = x =&gt; (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;
  
  
  
      }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/Yemgp.png" alt="enter image description here"></p>
  
  <p>Thanks in advance for your help and comments</p>