locked
Vertical menu bar at the left with various tabs and tree inside the tabs. RRS feed

  • Question

  • Hello, I would like to get a menu like have outlook 2003, with a vertical menu with tabs and inside the tabs, trees.

    Do you knwo where could I find a example? or if exist this tool inside the visual studio 2008?

    Thanks a lot
    fmorales
    Saturday, September 27, 2008 4:10 PM

Answers

  •  

    Hello,

           I think it is not difficult to define such a UserControl on our own.   Please refer to the following codes:


    ------------------------------------------------------------------------------------------
        public
    partial class UserControl1 : UserControl

        {

            const int TAB_WIDTH = 160;

            const int TAB_HEIGHT = 66;

            const int TREEVIEW_HEIGHT = 240;

            const int CONTROL_WIDTH = 162;

            const int CONTROL_HEIGHT = 520;

     

            private Button button1 = new Button();

            private Button button2 = new Button();

            private Button button3 = new Button();

            private Button button4 = new Button();

     

            private TreeView treeView1 = new TreeView();

            private TreeView treeView2 = new TreeView();

            private TreeView treeView3 = new TreeView();

            private TreeView treeView4 = new TreeView();

     

            public UserControl1()

            {

                this.button1 = new System.Windows.Forms.Button();

                this.button2 = new System.Windows.Forms.Button();

                this.button3 = new System.Windows.Forms.Button();

                this.button4 = new System.Windows.Forms.Button();

                this.SuspendLayout();

                //

                // button1

                //

                this.button1.BackColor = System.Drawing.Color.SkyBlue;

                this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;

                this.button1.Location = new System.Drawing.Point(0, 0);

                this.button1.Name = "button1";

                this.button1.Size = new System.Drawing.Size(TAB_WIDTH, TAB_HEIGHT);

                this.button1.TabIndex = 0;

                this.button1.Text = "button1";

                this.button1.UseVisualStyleBackColor = false;

                this.button1.Click += new System.EventHandler(this.button1_Click);

                //

                // button2

                //

                this.button2.BackColor = System.Drawing.Color.SkyBlue;

                this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;

                this.button2.Location = new System.Drawing.Point(0, TAB_HEIGHT + TREEVIEW_HEIGHT + 6);

                this.button2.Name = "button2";

                this.button2.Size = new System.Drawing.Size(TAB_WIDTH, TAB_HEIGHT);

                this.button2.TabIndex = 1;

                this.button2.Text = "button2";

                this.button2.UseVisualStyleBackColor = false;

                this.button2.Click += new System.EventHandler(this.button2_Click);

                //

                // button3

                //

                this.button3.BackColor = System.Drawing.Color.SkyBlue;

                this.button3.FlatStyle = System.Windows.Forms.FlatStyle.Flat;

                this.button3.Location = new System.Drawing.Point(0, TAB_HEIGHT * 2 + TREEVIEW_HEIGHT + 6);

                this.button3.Name = "button3";

                this.button3.Size = new System.Drawing.Size(TAB_WIDTH, TAB_HEIGHT);

                this.button3.TabIndex = 2;

                this.button3.Text = "button3";

                this.button3.UseVisualStyleBackColor = false;

                this.button3.Click += new System.EventHandler(this.button3_Click);

                //

                // button4

                //

                this.button4.BackColor = System.Drawing.Color.SkyBlue;

                this.button4.FlatStyle = System.Windows.Forms.FlatStyle.Flat;

                this.button4.Location = new System.Drawing.Point(0, TAB_HEIGHT * 3 + TREEVIEW_HEIGHT + 6);

                this.button4.Name = "button4";

                this.button4.Size = new System.Drawing.Size(TAB_WIDTH, TAB_HEIGHT);

                this.button4.TabIndex = 3;

                this.button4.Text = "button4";

                this.button4.UseVisualStyleBackColor = false;

                this.button4.Click += new System.EventHandler(this.button4_Click);

                //

                // UserControl1

                //

                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

                this.BackColor = System.Drawing.Color.White;

                this.Controls.Add(this.button4);

                this.Controls.Add(this.button3);

                this.Controls.Add(this.button2);

                this.Controls.Add(this.button1);

                this.Name = "UserControl1";

                this.Size = new System.Drawing.Size(CONTROL_WIDTH, CONTROL_HEIGHT);

                this.ResumeLayout(false);

                //

                //treeView1

                //

                this.treeView1.Visible = true;

                this.treeView1.Location = new Point(0, TAB_HEIGHT + 3);

                this.treeView1.Size = new Size(TAB_WIDTH, TREEVIEW_HEIGHT);

                this.treeView1.TabIndex = 4;

                this.treeView1.Name = "treeView1";

                //

                //treeView2

                //

                this.treeView2.Size = new Size(TAB_WIDTH, TREEVIEW_HEIGHT);

                this.treeView2.TabIndex = 4;

                this.treeView2.Name = "treeView2";

                //

                //treeView3

                //

                this.treeView3.Size = new Size(TAB_WIDTH, TREEVIEW_HEIGHT);

                this.treeView3.TabIndex = 4;

                this.treeView3.Name = "treeView3";

                //

                //treeView4

                //

                this.treeView4.Size = new Size(TAB_WIDTH, TREEVIEW_HEIGHT);

                this.treeView4.TabIndex = 4;

                this.treeView4.Name = "treeView4";

     

                this.Controls.Add(this.treeView1);

            }

     

            private void button1_Click(object sender, EventArgs e)

            {

                if (!this.Controls.Contains(treeView1))

                {

                    this.treeView1.Visible = true;

                    this.treeView1.Location = new Point(0, TAB_HEIGHT + 3);

     

                    this.Controls.Clear();

                    this.button1.Location = new Point(0, 0);

                    this.button2.Location = new Point(0, TAB_HEIGHT + TREEVIEW_HEIGHT + 6);

                    this.button3.Location = new Point(0, TAB_HEIGHT * 2 + TREEVIEW_HEIGHT + 6);

                    this.button4.Location = new Point(0, TAB_HEIGHT * 3 + TREEVIEW_HEIGHT + 6);

                    this.Controls.Add(this.button1);

                    this.Controls.Add(this.button2);

                    this.Controls.Add(this.button3);

                    this.Controls.Add(this.button4);

                    this.Controls.Add(this.treeView1);

                }

            }

     

            private void button2_Click(object sender, EventArgs e)

            {

                if (!this.Controls.Contains(treeView2))

                {

                    this.treeView2.Visible = true;

                    this.treeView2.Location = new Point(0, TAB_HEIGHT * 2 + 3);

     

                    this.Controls.Clear();

                    this.button1.Location = new Point(0, 0);

                    this.button2.Location = new Point(0, TAB_HEIGHT);

                    this.button3.Location = new Point(0, TAB_HEIGHT * 2 + TREEVIEW_HEIGHT + 6);

                    this.button4.Location = new Point(0, TAB_HEIGHT * 3 + TREEVIEW_HEIGHT + 6);

                    this.Controls.Add(this.button1);

                    this.Controls.Add(this.button2);

                    this.Controls.Add(this.button3);

                    this.Controls.Add(this.button4);

                    this.Controls.Add(this.treeView2);

                }

            }

     

            private void button3_Click(object sender, EventArgs e)

            {

                if (!this.Controls.Contains(treeView3))

                {

                    this.treeView3.Visible = true;

                    this.treeView3.Location = new Point(0, TAB_HEIGHT * 3 + 3);

     

                    this.Controls.Clear();

                    this.button1.Location = new Point(0, 0);

                    this.button2.Location = new Point(0, TAB_HEIGHT);

                    this.button3.Location = new Point(0, TAB_HEIGHT * 2);

                    this.button4.Location = new Point(0, TAB_HEIGHT * 3 + TREEVIEW_HEIGHT + 6);

                    this.Controls.Add(this.button1);

                    this.Controls.Add(this.button2);

                    this.Controls.Add(this.button3);

                    this.Controls.Add(this.button4);

                    this.Controls.Add(this.treeView3);

                }

            }

     

            private void button4_Click(object sender, EventArgs e)

            {

                if (!this.Controls.Contains(treeView4))

                {

                    this.treeView4.Visible = true;

                    this.treeView4.Location = new Point(0, TAB_HEIGHT * 4 + 3);

     

                    this.Controls.Clear();

                    this.button1.Location = new Point(0, 0);

                    this.button2.Location = new Point(0, TAB_HEIGHT);

                    this.button3.Location = new Point(0, TAB_HEIGHT * 2);

                    this.button4.Location = new Point(0, TAB_HEIGHT * 3);

                    this.Controls.Add(this.button1);

                    this.Controls.Add(this.button2);

                    this.Controls.Add(this.button3);

                    this.Controls.Add(this.button4);

                    this.Controls.Add(this.treeView4);

                }

            }

        }

    --------------------------------------------------------------------------------------------------------------------------

           In this UserControl, we have four regular buttons and four TreeView control, you could also modify the function according to your own target, I think it won’t be very difficult.     

           Of course, if you have some other demand, please just let me know, I will try my best to help.

     

           Thanks,

    Best Regards,
    Lingzhi


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. http://forums.msdn.microsoft.com/en-US/csharpide/thread/8e9ed0d7-11ff-402a-8489-9b5f05eeb706 http://forums.msdn.microsoft.com/en-US/vssetup/thread/60424309-bd78-4ca2-b618-03c4a16123b6
    Wednesday, October 1, 2008 6:15 AM