Click here to Skip to main content
16,022,536 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I'm looking for a solution (or component) how to show someting like this in a treeView

A
|
|--B
| |--C
|
|-----D

There is missing (hidden) node between root A na D node. But D is indented to C position.

Is there any (easy) way how to achieve this?

Thanks
Posted

1 solution

is this what you what?:screen shot

if so,

you can do this in the designer but here's the code:
private void InitializeComponent()
        {
            System.Windows.Forms.TreeNode treeNode1 = new System.Windows.Forms.TreeNode("A");
            System.Windows.Forms.TreeNode treeNode2 = new System.Windows.Forms.TreeNode("C");
            System.Windows.Forms.TreeNode treeNode3 = new System.Windows.Forms.TreeNode("D");
            System.Windows.Forms.TreeNode treeNode4 = new System.Windows.Forms.TreeNode("G");
            System.Windows.Forms.TreeNode treeNode5 = new System.Windows.Forms.TreeNode("F", new System.Windows.Forms.TreeNode[] {
            treeNode4});
            System.Windows.Forms.TreeNode treeNode6 = new System.Windows.Forms.TreeNode("B", new System.Windows.Forms.TreeNode[] {
            treeNode2,
            treeNode3,
            treeNode5});
            System.Windows.Forms.TreeNode treeNode7 = new System.Windows.Forms.TreeNode("H");
            this.treeView1 = new System.Windows.Forms.TreeView();
            this.SuspendLayout();
            // 
            // treeView1
            // 
            this.treeView1.Location = new System.Drawing.Point(57, 63);
            this.treeView1.Name = "treeView1";
            treeNode1.Name = "Node0";
            treeNode1.Text = "A";
            treeNode2.Name = "Node4";
            treeNode2.Text = "C";
            treeNode3.Name = "Node5";
            treeNode3.Text = "D";
            treeNode4.Name = "Node7";
            treeNode4.Text = "G";
            treeNode5.Name = "Node6";
            treeNode5.Text = "F";
            treeNode6.Name = "Node2";
            treeNode6.Text = "B";
            treeNode7.Name = "Node3";
            treeNode7.Text = "H";
            this.treeView1.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
            treeNode1,
            treeNode6,
            treeNode7});
            this.treeView1.Size = new System.Drawing.Size(217, 172);
            this.treeView1.TabIndex = 0;
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(405, 341);
            this.Controls.Add(this.treeView1);
            this.Name = "Form1";
            this.Text = "Form1";
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.TreeView treeView1;
 
Share this answer
 
v3
Comments
shark1546 13-Aug-10 1:16am    
Unfortunately not. What I wanted is "invisible" node between nodes. Please look at http://shark1546.rajce.idnes.cz/nastenka/#RaggedTreeView.jpg
There is "missing" node before H node. Normaly there should be some node before H at position below A and B.
This is what I want to achieve.

Thanks
me773 13-Aug-10 16:35pm    
aren't they the same?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900