TreeView控件的应用

下面展示的是一个用Treeview控件编辑的一个住房信息管理系统的简单domo,其中Form1为主界面,Form2象征性的展示每一个子项:

Form1:

namespace 用树型列表动态显示菜单
{
    partial class Form1
    {
        /// <summary>
        /// 必需的设计器变量。
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// 清理所有正在使用的资源。
        /// </summary>
        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows 窗体设计器生成的代码

        /// <summary>
        /// 设计器支持所需的方法 - 不要
        /// 使用代码编辑器修改此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.menuStrip1 = new System.Windows.Forms.MenuStrip();
            this.ToolStrip_1_0 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_1 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_2 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_3 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_2_0 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_4 = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_5 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_6 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_3_0 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_7 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_18 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_19 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_8 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_4_0 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_9 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_10 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_11 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_12 = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripMenuItem7 = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripMenuItem6 = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_13 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_14 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_5_0 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_15 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_16 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_6_0 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_17 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_7_0 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_21 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_22 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_23 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_24 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_8_0 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_25 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_26 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_27 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_28 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_29 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_9_0 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_30 = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStrip1 = new System.Windows.Forms.ToolStrip();
            this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
            this.toolStripButton2 = new System.Windows.Forms.ToolStripButton();
            this.toolStripButton3 = new System.Windows.Forms.ToolStripButton();
            this.toolStripButton4 = new System.Windows.Forms.ToolStripButton();
            this.toolStripButton5 = new System.Windows.Forms.ToolStripButton();
            this.panel_Tree = new System.Windows.Forms.Panel();
            this.treeView1 = new System.Windows.Forms.TreeView();
            this.pictureBox1 = new System.Windows.Forms.PictureBox();
            this.menuStrip1.SuspendLayout();
            this.toolStrip1.SuspendLayout();
            this.panel_Tree.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
            this.SuspendLayout();
            //
            // menuStrip1
            //
            this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.ToolStrip_1_0,
            this.ToolStrip_2_0,
            this.ToolStrip_3_0,
            this.ToolStrip_4_0,
            this.ToolStrip_5_0,
            this.ToolStrip_6_0,
            this.ToolStrip_7_0,
            this.ToolStrip_8_0,
            this.ToolStrip_9_0});
            this.menuStrip1.Location = new System.Drawing.Point(0, 0);
            this.menuStrip1.Name = "menuStrip1";
            this.menuStrip1.Size = new System.Drawing.Size(641, 24);
            this.menuStrip1.TabIndex = 1;
            this.menuStrip1.Text = "menuStrip1";
            //
            // ToolStrip_1_0
            //
            this.ToolStrip_1_0.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.ToolStrip_1,
            this.ToolStrip_2,
            this.ToolStrip_3});
            this.ToolStrip_1_0.Name = "ToolStrip_1_0";
            this.ToolStrip_1_0.Size = new System.Drawing.Size(89, 20);
            this.ToolStrip_1_0.Tag = "0";
            this.ToolStrip_1_0.Text = "用户信息管理";
            //
            // ToolStrip_1
            //
            this.ToolStrip_1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.ToolStrip_1.Name = "ToolStrip_1";
            this.ToolStrip_1.Size = new System.Drawing.Size(166, 22);
            this.ToolStrip_1.Tag = "1";
            this.ToolStrip_1.Text = "求租人员信息设置";
            this.ToolStrip_1.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_2
            //
            this.ToolStrip_2.Name = "ToolStrip_2";
            this.ToolStrip_2.Size = new System.Drawing.Size(166, 22);
            this.ToolStrip_2.Tag = "2";
            this.ToolStrip_2.Text = "出租人员信息设置";
            this.ToolStrip_2.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_3
            //
            this.ToolStrip_3.Name = "ToolStrip_3";
            this.ToolStrip_3.Size = new System.Drawing.Size(166, 22);
            this.ToolStrip_3.Tag = "3";
            this.ToolStrip_3.Text = "人员信息控制";
            this.ToolStrip_3.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_2_0
            //
            this.ToolStrip_2_0.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.ToolStrip_4,
            this.toolStripMenuItem2,
            this.toolStripMenuItem1,
            this.ToolStrip_5,
            this.ToolStrip_6});
            this.ToolStrip_2_0.Enabled = false;
            this.ToolStrip_2_0.Name = "ToolStrip_2_0";
            this.ToolStrip_2_0.Size = new System.Drawing.Size(65, 20);
            this.ToolStrip_2_0.Tag = "0";
            this.ToolStrip_2_0.Text = "求租管理";
            //
            // ToolStrip_4
            //
            this.ToolStrip_4.Name = "ToolStrip_4";
            this.ToolStrip_4.Size = new System.Drawing.Size(142, 22);
            this.ToolStrip_4.Tag = "4";
            this.ToolStrip_4.Text = "房源查询设置";
            this.ToolStrip_4.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // toolStripMenuItem2
            //
            this.toolStripMenuItem2.Name = "toolStripMenuItem2";
            this.toolStripMenuItem2.Size = new System.Drawing.Size(142, 22);
            this.toolStripMenuItem2.Tag = "5";
            this.toolStripMenuItem2.Text = "房源状态浏览";
            this.toolStripMenuItem2.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // toolStripMenuItem1
            //
            this.toolStripMenuItem1.Name = "toolStripMenuItem1";
            this.toolStripMenuItem1.Size = new System.Drawing.Size(142, 22);
            this.toolStripMenuItem1.Tag = "4";
            this.toolStripMenuItem1.Text = "房源查询设置";
            this.toolStripMenuItem1.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_5
            //
            this.ToolStrip_5.Name = "ToolStrip_5";
            this.ToolStrip_5.Size = new System.Drawing.Size(142, 22);
            this.ToolStrip_5.Tag = "5";
            this.ToolStrip_5.Text = "房源状态浏览";
            this.ToolStrip_5.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_6
            //
            this.ToolStrip_6.Name = "ToolStrip_6";
            this.ToolStrip_6.Size = new System.Drawing.Size(142, 22);
            this.ToolStrip_6.Tag = "6";
            this.ToolStrip_6.Text = "求租意向设置";
            this.ToolStrip_6.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_3_0
            //
            this.ToolStrip_3_0.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.ToolStrip_7,
            this.ToolStrip_8});
            this.ToolStrip_3_0.Name = "ToolStrip_3_0";
            this.ToolStrip_3_0.Size = new System.Drawing.Size(65, 20);
            this.ToolStrip_3_0.Tag = "0";
            this.ToolStrip_3_0.Text = "员工信息";
            //
            // ToolStrip_7
            //
            this.ToolStrip_7.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.ToolStrip_18,
            this.ToolStrip_19});
            this.ToolStrip_7.Name = "ToolStrip_7";
            this.ToolStrip_7.Size = new System.Drawing.Size(142, 22);
            this.ToolStrip_7.Tag = "0";
            this.ToolStrip_7.Text = "录入员工信息";
            this.ToolStrip_7.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_18
            //
            this.ToolStrip_18.Name = "ToolStrip_18";
            this.ToolStrip_18.Size = new System.Drawing.Size(142, 22);
            this.ToolStrip_18.Tag = "18";
            this.ToolStrip_18.Text = "单个信息录入";
            this.ToolStrip_18.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_19
            //
            this.ToolStrip_19.Enabled = false;
            this.ToolStrip_19.Name = "ToolStrip_19";
            this.ToolStrip_19.Size = new System.Drawing.Size(142, 22);
            this.ToolStrip_19.Tag = "19";
            this.ToolStrip_19.Text = "批量信息录入";
            this.ToolStrip_19.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_8
            //
            this.ToolStrip_8.Name = "ToolStrip_8";
            this.ToolStrip_8.Size = new System.Drawing.Size(142, 22);
            this.ToolStrip_8.Tag = "8";
            this.ToolStrip_8.Text = "所有员工信息";
            this.ToolStrip_8.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_4_0
            //
            this.ToolStrip_4_0.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.ToolStrip_9,
            this.ToolStrip_10,
            this.ToolStrip_11,
            this.ToolStrip_12,
            this.toolStripMenuItem7,
            this.toolStripMenuItem6,
            this.toolStripMenuItem5,
            this.toolStripMenuItem4,
            this.toolStripMenuItem3,
            this.ToolStrip_13,
            this.ToolStrip_14});
            this.ToolStrip_4_0.Name = "ToolStrip_4_0";
            this.ToolStrip_4_0.Size = new System.Drawing.Size(65, 20);
            this.ToolStrip_4_0.Tag = "0";
            this.ToolStrip_4_0.Text = "出租管理";
            //
            // ToolStrip_9
            //
            this.ToolStrip_9.Name = "ToolStrip_9";
            this.ToolStrip_9.Size = new System.Drawing.Size(142, 22);
            this.ToolStrip_9.Tag = "9";
            this.ToolStrip_9.Text = "房型信息设置";
            this.ToolStrip_9.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_10
            //
            this.ToolStrip_10.Enabled = false;
            this.ToolStrip_10.Name = "ToolStrip_10";
            this.ToolStrip_10.Size = new System.Drawing.Size(142, 22);
            this.ToolStrip_10.Tag = "10";
            this.ToolStrip_10.Text = "楼层设置";
            this.ToolStrip_10.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_11
            //
            this.ToolStrip_11.Name = "ToolStrip_11";
            this.ToolStrip_11.Size = new System.Drawing.Size(142, 22);
            this.ToolStrip_11.Tag = "11";
            this.ToolStrip_11.Text = "幢/座设置";
            this.ToolStrip_11.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_12
            //
            this.ToolStrip_12.Enabled = false;
            this.ToolStrip_12.Name = "ToolStrip_12";
            this.ToolStrip_12.Size = new System.Drawing.Size(142, 22);
            this.ToolStrip_12.Tag = "12";
            this.ToolStrip_12.Text = "装修程度设置";
            this.ToolStrip_12.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // toolStripMenuItem7
            //
            this.toolStripMenuItem7.Name = "toolStripMenuItem7";
            this.toolStripMenuItem7.Size = new System.Drawing.Size(142, 22);
            this.toolStripMenuItem7.Tag = "13";
            this.toolStripMenuItem7.Text = "朝向设置";
            this.toolStripMenuItem7.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // toolStripMenuItem6
            //
            this.toolStripMenuItem6.Enabled = false;
            this.toolStripMenuItem6.Name = "toolStripMenuItem6";
            this.toolStripMenuItem6.Size = new System.Drawing.Size(142, 22);
            this.toolStripMenuItem6.Tag = "12";
            this.toolStripMenuItem6.Text = "装修程度设置";
            this.toolStripMenuItem6.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // toolStripMenuItem5
            //
            this.toolStripMenuItem5.Name = "toolStripMenuItem5";
            this.toolStripMenuItem5.Size = new System.Drawing.Size(142, 22);
            this.toolStripMenuItem5.Tag = "11";
            this.toolStripMenuItem5.Text = "幢/座设置";
            this.toolStripMenuItem5.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // toolStripMenuItem4
            //
            this.toolStripMenuItem4.Enabled = false;
            this.toolStripMenuItem4.Name = "toolStripMenuItem4";
            this.toolStripMenuItem4.Size = new System.Drawing.Size(142, 22);
            this.toolStripMenuItem4.Tag = "10";
            this.toolStripMenuItem4.Text = "楼层设置";
            this.toolStripMenuItem4.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // toolStripMenuItem3
            //
            this.toolStripMenuItem3.Name = "toolStripMenuItem3";
            this.toolStripMenuItem3.Size = new System.Drawing.Size(142, 22);
            this.toolStripMenuItem3.Tag = "9";
            this.toolStripMenuItem3.Text = "房型信息设置";
            this.toolStripMenuItem3.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_13
            //
            this.ToolStrip_13.Name = "ToolStrip_13";
            this.ToolStrip_13.Size = new System.Drawing.Size(142, 22);
            this.ToolStrip_13.Tag = "13";
            this.ToolStrip_13.Text = "朝向设置";
            this.ToolStrip_13.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_14
            //
            this.ToolStrip_14.Name = "ToolStrip_14";
            this.ToolStrip_14.Size = new System.Drawing.Size(142, 22);
            this.ToolStrip_14.Tag = "14";
            this.ToolStrip_14.Text = "用途设置";
            this.ToolStrip_14.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_5_0
            //
            this.ToolStrip_5_0.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.ToolStrip_15,
            this.ToolStrip_16});
            this.ToolStrip_5_0.Name = "ToolStrip_5_0";
            this.ToolStrip_5_0.Size = new System.Drawing.Size(65, 20);
            this.ToolStrip_5_0.Tag = "0";
            this.ToolStrip_5_0.Text = "交费管理";
            //
            // ToolStrip_15
            //
            this.ToolStrip_15.Name = "ToolStrip_15";
            this.ToolStrip_15.Size = new System.Drawing.Size(118, 22);
            this.ToolStrip_15.Tag = "15";
            this.ToolStrip_15.Text = "收费设置";
            this.ToolStrip_15.Visible = false;
            this.ToolStrip_15.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_16
            //
            this.ToolStrip_16.Name = "ToolStrip_16";
            this.ToolStrip_16.Size = new System.Drawing.Size(118, 22);
            this.ToolStrip_16.Tag = "16";
            this.ToolStrip_16.Text = "收费记录";
            this.ToolStrip_16.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_6_0
            //
            this.ToolStrip_6_0.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.ToolStrip_17});
            this.ToolStrip_6_0.Name = "ToolStrip_6_0";
            this.ToolStrip_6_0.Size = new System.Drawing.Size(65, 20);
            this.ToolStrip_6_0.Tag = "0";
            this.ToolStrip_6_0.Text = "业务统计";
            //
            // ToolStrip_17
            //
            this.ToolStrip_17.Name = "ToolStrip_17";
            this.ToolStrip_17.Size = new System.Drawing.Size(154, 22);
            this.ToolStrip_17.Tag = "17";
            this.ToolStrip_17.Text = "成交业务量统计";
            this.ToolStrip_17.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_7_0
            //
            this.ToolStrip_7_0.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.ToolStrip_21,
            this.ToolStrip_22,
            this.ToolStrip_23,
            this.ToolStrip_24});
            this.ToolStrip_7_0.Name = "ToolStrip_7_0";
            this.ToolStrip_7_0.Size = new System.Drawing.Size(65, 20);
            this.ToolStrip_7_0.Tag = "0";
            this.ToolStrip_7_0.Text = "常用工具";
            //
            // ToolStrip_21
            //
            this.ToolStrip_21.Name = "ToolStrip_21";
            this.ToolStrip_21.Size = new System.Drawing.Size(106, 22);
            this.ToolStrip_21.Tag = "21";
            this.ToolStrip_21.Text = "记事本";
            this.ToolStrip_21.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_22
            //
            this.ToolStrip_22.Name = "ToolStrip_22";
            this.ToolStrip_22.Size = new System.Drawing.Size(106, 22);
            this.ToolStrip_22.Tag = "22";
            this.ToolStrip_22.Text = "记算器";
            this.ToolStrip_22.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_23
            //
            this.ToolStrip_23.Name = "ToolStrip_23";
            this.ToolStrip_23.Size = new System.Drawing.Size(106, 22);
            this.ToolStrip_23.Tag = "23";
            this.ToolStrip_23.Text = "WORD";
            this.ToolStrip_23.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_24
            //
            this.ToolStrip_24.Name = "ToolStrip_24";
            this.ToolStrip_24.Size = new System.Drawing.Size(106, 22);
            this.ToolStrip_24.Tag = "24";
            this.ToolStrip_24.Text = "EXCEL";
            this.ToolStrip_24.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_8_0
            //
            this.ToolStrip_8_0.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.ToolStrip_25,
            this.ToolStrip_26,
            this.ToolStrip_27,
            this.ToolStrip_28,
            this.ToolStrip_29});
            this.ToolStrip_8_0.Name = "ToolStrip_8_0";
            this.ToolStrip_8_0.Size = new System.Drawing.Size(65, 20);
            this.ToolStrip_8_0.Tag = "0";
            this.ToolStrip_8_0.Text = "系统管理";
            //
            // ToolStrip_25
            //
            this.ToolStrip_25.Name = "ToolStrip_25";
            this.ToolStrip_25.Size = new System.Drawing.Size(142, 22);
            this.ToolStrip_25.Tag = "25";
            this.ToolStrip_25.Text = "口令设置";
            this.ToolStrip_25.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_26
            //
            this.ToolStrip_26.Name = "ToolStrip_26";
            this.ToolStrip_26.Size = new System.Drawing.Size(142, 22);
            this.ToolStrip_26.Tag = "26";
            this.ToolStrip_26.Text = "退出系统";
            this.ToolStrip_26.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_27
            //
            this.ToolStrip_27.Name = "ToolStrip_27";
            this.ToolStrip_27.Size = new System.Drawing.Size(142, 22);
            this.ToolStrip_27.Tag = "27";
            this.ToolStrip_27.Text = "数据库备份";
            this.ToolStrip_27.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_28
            //
            this.ToolStrip_28.Name = "ToolStrip_28";
            this.ToolStrip_28.Size = new System.Drawing.Size(142, 22);
            this.ToolStrip_28.Tag = "28";
            this.ToolStrip_28.Text = "数据库恢复";
            this.ToolStrip_28.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_29
            //
            this.ToolStrip_29.Name = "ToolStrip_29";
            this.ToolStrip_29.Size = new System.Drawing.Size(142, 22);
            this.ToolStrip_29.Tag = "29";
            this.ToolStrip_29.Text = "清理无效信息";
            this.ToolStrip_29.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_9_0
            //
            this.ToolStrip_9_0.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.ToolStrip_30});
            this.ToolStrip_9_0.Name = "ToolStrip_9_0";
            this.ToolStrip_9_0.Size = new System.Drawing.Size(41, 20);
            this.ToolStrip_9_0.Tag = "0";
            this.ToolStrip_9_0.Text = "帮助";
            //
            // ToolStrip_30
            //
            this.ToolStrip_30.Name = "ToolStrip_30";
            this.ToolStrip_30.Size = new System.Drawing.Size(118, 22);
            this.ToolStrip_30.Tag = "30";
            this.ToolStrip_30.Text = "帮助文件";
            this.ToolStrip_30.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // toolStrip1
            //
            this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.toolStripButton1,
            this.toolStripButton2,
            this.toolStripButton3,
            this.toolStripButton4,
            this.toolStripButton5});
            this.toolStrip1.Location = new System.Drawing.Point(0, 24);
            this.toolStrip1.Name = "toolStrip1";
            this.toolStrip1.Size = new System.Drawing.Size(641, 25);
            this.toolStrip1.TabIndex = 4;
            this.toolStrip1.Text = "toolStrip1";
            //
            // toolStripButton1
            //
            this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image")));
            this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton1.Name = "toolStripButton1";
            this.toolStripButton1.Size = new System.Drawing.Size(97, 22);
            this.toolStripButton1.Tag = "1";
            this.toolStripButton1.Text = "求租人员信息";
            this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click);
            //
            // toolStripButton2
            //
            this.toolStripButton2.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton2.Image")));
            this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton2.Name = "toolStripButton2";
            this.toolStripButton2.Size = new System.Drawing.Size(121, 22);
            this.toolStripButton2.Tag = "2";
            this.toolStripButton2.Text = "出租人员信息设置";
            this.toolStripButton2.Click += new System.EventHandler(this.toolStripButton1_Click);
            //
            // toolStripButton3
            //
            this.toolStripButton3.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton3.Image")));
            this.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton3.Name = "toolStripButton3";
            this.toolStripButton3.Size = new System.Drawing.Size(97, 22);
            this.toolStripButton3.Tag = "4";
            this.toolStripButton3.Text = "房源查询设置";
            this.toolStripButton3.Click += new System.EventHandler(this.toolStripButton1_Click);
            //
            // toolStripButton4
            //
            this.toolStripButton4.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton4.Image")));
            this.toolStripButton4.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton4.Name = "toolStripButton4";
            this.toolStripButton4.Size = new System.Drawing.Size(73, 22);
            this.toolStripButton4.Tag = "16";
            this.toolStripButton4.Text = "收费记录";
            this.toolStripButton4.Click += new System.EventHandler(this.toolStripButton1_Click);
            //
            // toolStripButton5
            //
            this.toolStripButton5.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton5.Image")));
            this.toolStripButton5.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton5.Name = "toolStripButton5";
            this.toolStripButton5.Size = new System.Drawing.Size(109, 22);
            this.toolStripButton5.Tag = "17";
            this.toolStripButton5.Text = "成交业务量统计";
            this.toolStripButton5.Click += new System.EventHandler(this.toolStripButton1_Click);
            //
            // panel_Tree
            //
            this.panel_Tree.Controls.Add(this.treeView1);
            this.panel_Tree.Dock = System.Windows.Forms.DockStyle.Left;
            this.panel_Tree.Location = new System.Drawing.Point(0, 49);
            this.panel_Tree.Name = "panel_Tree";
            this.panel_Tree.Size = new System.Drawing.Size(192, 374);
            this.panel_Tree.TabIndex = 5;
            //
            // treeView1
            //
            this.treeView1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.treeView1.Location = new System.Drawing.Point(0, 0);
            this.treeView1.Name = "treeView1";
            this.treeView1.Size = new System.Drawing.Size(192, 374);
            this.treeView1.TabIndex = 8;
            this.treeView1.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseDoubleClick);
            //
            // pictureBox1
            //
            this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.pictureBox1.Image = global::用树型列表动态显示菜单.Properties.Resources._1;
            this.pictureBox1.Location = new System.Drawing.Point(192, 49);
            this.pictureBox1.Name = "pictureBox1";
            this.pictureBox1.Size = new System.Drawing.Size(449, 374);
            this.pictureBox1.TabIndex = 6;
            this.pictureBox1.TabStop = false;
            //
            // Form1
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(641, 423);
            this.Controls.Add(this.pictureBox1);
            this.Controls.Add(this.panel_Tree);
            this.Controls.Add(this.toolStrip1);
            this.Controls.Add(this.menuStrip1);
            this.Name = "Form1";
            this.Text = "用树型列表动态显示菜单";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.menuStrip1.ResumeLayout(false);
            this.menuStrip1.PerformLayout();
            this.toolStrip1.ResumeLayout(false);
            this.toolStrip1.PerformLayout();
            this.panel_Tree.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.MenuStrip menuStrip1;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_1_0;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_1;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_2;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_3;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_2_0;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_4;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_5;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_6;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_3_0;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_7;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_8;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_4_0;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_9;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_10;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_11;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_12;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_13;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_14;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_5_0;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_15;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_16;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_6_0;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_17;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_7_0;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_21;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_22;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_23;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_24;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_8_0;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_25;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_26;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_27;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_28;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_29;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_9_0;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_30;
        private System.Windows.Forms.ToolStrip toolStrip1;
        private System.Windows.Forms.ToolStripButton toolStripButton1;
        private System.Windows.Forms.ToolStripButton toolStripButton2;
        private System.Windows.Forms.ToolStripButton toolStripButton3;
        private System.Windows.Forms.ToolStripButton toolStripButton4;
        private System.Windows.Forms.ToolStripButton toolStripButton5;
        private System.Windows.Forms.Panel panel_Tree;
        private System.Windows.Forms.TreeView treeView1;
        private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
        private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
        private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem7;
        private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem6;
        private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem5;
        private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem4;
        private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem3;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_18;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_19;
        private System.Windows.Forms.PictureBox pictureBox1;
    }
}

Designer.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 用树型列表动态显示菜单
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        #region  将MenuStrip控件中的信息添加到TreeView控件中
        /// <summary>
        /// 将MenuStrip控件中的首行命令项添加到TreeView控件中
        /// </summary>
        /// <param treeV="TreeView">TreeView控件</param>
        /// <param MenuS="MenuStrip">MenuStrip控件</param>
        public void GetMenu(TreeView treeV, MenuStrip MenuS)
        {
            bool Var_Bool = true;
            for (int i = 0; i < MenuS.Items.Count; i++) //遍历MenuStrip组件中的一级菜单项
            {
                //将一级菜单项的名称添加到TreeView组件的根节点中,并设置当前节点的子节点newNode1
                TreeNode newNode1 = treeV.Nodes.Add(MenuS.Items[i].Text);
                if (MenuS.Items[i].Enabled == false)//判断当前项是否为可用
                {
                    newNode1.ForeColor = Color.Silver;//改变树节点的字体颜色为不可用色
                    Var_Bool = false;
                }
                else
                {
                    newNode1.ForeColor = Color.Black;//改变树节点的字体颜色为可用色
                    Var_Bool = true;
                }
                newNode1.Tag = 0;//标识,有子项的命令项
                //将当前菜单项的所有相关信息存入到ToolStripDropDownItem对象中
                ToolStripDropDownItem newmenu = (ToolStripDropDownItem)MenuS.Items[i];
                GetCavernMenu(newNode1, newmenu, Var_Bool);//添加多层命令项
            }
        }

        /// <summary>
        /// 将MenuStrip控件中的多层命今项添加到TreeView控件中
        /// </summary>
        /// <param newNodeA="TreeNode">TreeNode对象</param>
        /// <param newmenuA="ToolStripDropDownItem">ToolStripDropDownItem对象</param>
        /// <param BL="bool">标识(是否可用)</param>
        public void GetCavernMenu(TreeNode newNodeA, ToolStripDropDownItem newmenuA, bool BL)
        {
            bool Var_Bool = true;
            if (newmenuA.HasDropDownItems && newmenuA.DropDownItems.Count > 0)
                for (int j = 0; j < newmenuA.DropDownItems.Count; j++)    //遍历二级菜单项
                {
                    //将二级菜单名称添加到TreeView组件的子节点newNode1中,并设置当前节点的子节点newNode2
                    TreeNode newNodeB = newNodeA.Nodes.Add(newmenuA.DropDownItems[j].Text);
                    Var_Bool = true;
                    if (BL == false)//判断当前命令项的上一级命令是否可用
                    {
                        newNodeB.ForeColor = Color.Silver;//设置当前命令项的字体颜色为不可用色
                        newNodeB.Tag = 0;//标识,不显示相应的窗体
                        Var_Bool = false;
                    }
                    else
                    {
                        if (newmenuA.DropDownItems[j].Enabled == false)//判断当前命令项是否为可用
                        {
                            newNodeB.ForeColor = Color.Silver;//设置当前命令项的字体颜色为不可用色
                            newNodeB.Tag = 0;//标识,不显示相应的窗体
                            Var_Bool = false;
                        }
                        else
                        {
                            newNodeA.ForeColor = Color.Black;//设置当前命令项的字体颜色为可用色
                            newNodeB.Tag = int.Parse(newmenuA.DropDownItems[j].Tag.ToString());//标识,显示相应的窗体
                        }
                    }
                    //将当前菜单项的所有相关信息存入到ToolStripDropDownItem对象中
                    ToolStripDropDownItem newmenuB = (ToolStripDropDownItem)newmenuA.DropDownItems[j];
                    if (newmenuB.HasDropDownItems && newmenuA.DropDownItems.Count > 0)//如果当前命令项有子项
                    {
                        newNodeB.Tag = 0;//标识,有子项的命令项
                        GetCavernMenu(newNodeB, newmenuB, Var_Bool);//调用递归方法
                    }
                }
        }
        #endregion

        #region  打开MenuStrip控件或TreeView控件相应的窗体
        /// <summary>
        /// 打开MenuStrip控件或TreeView控件相应的窗体
        /// </summary>
        /// <param n="int">标识</param>
        /// <param FName="string">名称</param>
        public void frm_show(int n, string FName)
        {
            switch (n)//通过标识调用各子窗体
            {
                case 0: break;
                case 1:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 2:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 3:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 4:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 5:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 6:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 7:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 8:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 9:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 10:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 11:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 12:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 13:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 14:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 15:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 16:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 17:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 18:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 19:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 21:
                    {
                        //打开记事本
                        System.Diagnostics.Process.Start("notepad.exe");
                        break;
                    }
                case 22:
                    {
                        //打开计算器
                        System.Diagnostics.Process.Start("calc.exe");
                        break;
                    }
                case 23:
                    {
                        //打开WORD文档
                        System.Diagnostics.Process.Start("WINWORD.EXE");
                        break;
                    }
                case 24:
                    {
                        //打开EXCEL文件
                        System.Diagnostics.Process.Start("EXCEL.EXE");
                        break;
                    }
                case 25:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 26:
                    {
                        if (MessageBox.Show("确认退出系统吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                            Application.Exit();//关闭当前工程
                        break;
                    }
                case 27:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 28:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 29:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 30:
                    {
                        //打开帮助对话框
                        MessageBox.Show("\tBuild by Allen\t\n\n\t \n\t    谢谢使用!!");
                        break;
                    }
            }
        }
        #endregion

        private void Form1_Load(object sender, EventArgs e)
        {
            GetMenu(treeView1, menuStrip1);//将menuStrip1控件中的信息添加到treeView1控件中
        }

        private void ToolStrip_1_Click(object sender, EventArgs e)
        {
            frm_show(Convert.ToInt16(((ToolStripMenuItem)sender).Tag.ToString()), ((ToolStripMenuItem)sender).Text);
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            frm_show(Convert.ToInt16(((ToolStripButton)sender).Tag.ToString()), ((ToolStripButton)sender).Text);
        }

        private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            frm_show(Convert.ToInt16(e.Node.Tag.ToString()), e.Node.Text);
        }
    }
}

cs

Form2:

namespace 用树型列表动态显示菜单
{
    partial class Form2
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.SuspendLayout();
            //
            // Form2
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(292, 135);
            this.Name = "Form2";
            this.Text = "Form2";
            this.ResumeLayout(false);

        }

        #endregion
    }
}

Designer.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 用树型列表动态显示菜单
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
    }
}

cs

在上面的基础上,我们可以再添加一个用户登录的功能,即再添加一个Form在此将其命名为Frm_Logon,详细的Domo如下:

namespace 用树型列表动态显示菜单
{
    partial class Form1
    {
        /// <summary>
        /// 必需的设计器变量。
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// 清理所有正在使用的资源。
        /// </summary>
        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows 窗体设计器生成的代码

        /// <summary>
        /// 设计器支持所需的方法 - 不要
        /// 使用代码编辑器修改此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.menuStrip1 = new System.Windows.Forms.MenuStrip();
            this.ToolStrip_1_0 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_1 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_2 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_3 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_2_0 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_4 = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_5 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_6 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_3_0 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_7 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_18 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_19 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_8 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_4_0 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_9 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_10 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_11 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_12 = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripMenuItem7 = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripMenuItem6 = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_13 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_14 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_5_0 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_15 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_16 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_6_0 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_17 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_7_0 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_21 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_22 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_23 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_24 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_8_0 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_25 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_26 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_27 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_28 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_29 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_9_0 = new System.Windows.Forms.ToolStripMenuItem();
            this.ToolStrip_30 = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStrip1 = new System.Windows.Forms.ToolStrip();
            this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
            this.toolStripButton2 = new System.Windows.Forms.ToolStripButton();
            this.toolStripButton3 = new System.Windows.Forms.ToolStripButton();
            this.toolStripButton4 = new System.Windows.Forms.ToolStripButton();
            this.toolStripButton5 = new System.Windows.Forms.ToolStripButton();
            this.panel_Tree = new System.Windows.Forms.Panel();
            this.treeView1 = new System.Windows.Forms.TreeView();
            this.pictureBox1 = new System.Windows.Forms.PictureBox();
            this.menuStrip1.SuspendLayout();
            this.toolStrip1.SuspendLayout();
            this.panel_Tree.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
            this.SuspendLayout();
            //
            // menuStrip1
            //
            this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.ToolStrip_1_0,
            this.ToolStrip_2_0,
            this.ToolStrip_3_0,
            this.ToolStrip_4_0,
            this.ToolStrip_5_0,
            this.ToolStrip_6_0,
            this.ToolStrip_7_0,
            this.ToolStrip_8_0,
            this.ToolStrip_9_0});
            this.menuStrip1.Location = new System.Drawing.Point(0, 0);
            this.menuStrip1.Name = "menuStrip1";
            this.menuStrip1.Size = new System.Drawing.Size(641, 24);
            this.menuStrip1.TabIndex = 1;
            this.menuStrip1.Text = "menuStrip1";
            //
            // ToolStrip_1_0
            //
            this.ToolStrip_1_0.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.ToolStrip_1,
            this.ToolStrip_2,
            this.ToolStrip_3});
            this.ToolStrip_1_0.Name = "ToolStrip_1_0";
            this.ToolStrip_1_0.Size = new System.Drawing.Size(89, 20);
            this.ToolStrip_1_0.Tag = "0";
            this.ToolStrip_1_0.Text = "用户信息管理";
            //
            // ToolStrip_1
            //
            this.ToolStrip_1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.ToolStrip_1.Name = "ToolStrip_1";
            this.ToolStrip_1.Size = new System.Drawing.Size(166, 22);
            this.ToolStrip_1.Tag = "1";
            this.ToolStrip_1.Text = "求租人员信息设置";
            this.ToolStrip_1.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_2
            //
            this.ToolStrip_2.Name = "ToolStrip_2";
            this.ToolStrip_2.Size = new System.Drawing.Size(166, 22);
            this.ToolStrip_2.Tag = "2";
            this.ToolStrip_2.Text = "出租人员信息设置";
            this.ToolStrip_2.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_3
            //
            this.ToolStrip_3.Name = "ToolStrip_3";
            this.ToolStrip_3.Size = new System.Drawing.Size(166, 22);
            this.ToolStrip_3.Tag = "3";
            this.ToolStrip_3.Text = "人员信息控制";
            this.ToolStrip_3.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_2_0
            //
            this.ToolStrip_2_0.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.ToolStrip_4,
            this.toolStripMenuItem2,
            this.toolStripMenuItem1,
            this.ToolStrip_5,
            this.ToolStrip_6});
            this.ToolStrip_2_0.Enabled = false;
            this.ToolStrip_2_0.Name = "ToolStrip_2_0";
            this.ToolStrip_2_0.Size = new System.Drawing.Size(65, 20);
            this.ToolStrip_2_0.Tag = "0";
            this.ToolStrip_2_0.Text = "求租管理";
            //
            // ToolStrip_4
            //
            this.ToolStrip_4.Name = "ToolStrip_4";
            this.ToolStrip_4.Size = new System.Drawing.Size(142, 22);
            this.ToolStrip_4.Tag = "4";
            this.ToolStrip_4.Text = "房源查询设置";
            this.ToolStrip_4.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // toolStripMenuItem2
            //
            this.toolStripMenuItem2.Name = "toolStripMenuItem2";
            this.toolStripMenuItem2.Size = new System.Drawing.Size(142, 22);
            this.toolStripMenuItem2.Tag = "5";
            this.toolStripMenuItem2.Text = "房源状态浏览";
            this.toolStripMenuItem2.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // toolStripMenuItem1
            //
            this.toolStripMenuItem1.Name = "toolStripMenuItem1";
            this.toolStripMenuItem1.Size = new System.Drawing.Size(142, 22);
            this.toolStripMenuItem1.Tag = "4";
            this.toolStripMenuItem1.Text = "房源查询设置";
            this.toolStripMenuItem1.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_5
            //
            this.ToolStrip_5.Name = "ToolStrip_5";
            this.ToolStrip_5.Size = new System.Drawing.Size(142, 22);
            this.ToolStrip_5.Tag = "5";
            this.ToolStrip_5.Text = "房源状态浏览";
            this.ToolStrip_5.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_6
            //
            this.ToolStrip_6.Name = "ToolStrip_6";
            this.ToolStrip_6.Size = new System.Drawing.Size(142, 22);
            this.ToolStrip_6.Tag = "6";
            this.ToolStrip_6.Text = "求租意向设置";
            this.ToolStrip_6.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_3_0
            //
            this.ToolStrip_3_0.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.ToolStrip_7,
            this.ToolStrip_8});
            this.ToolStrip_3_0.Name = "ToolStrip_3_0";
            this.ToolStrip_3_0.Size = new System.Drawing.Size(65, 20);
            this.ToolStrip_3_0.Tag = "0";
            this.ToolStrip_3_0.Text = "员工信息";
            //
            // ToolStrip_7
            //
            this.ToolStrip_7.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.ToolStrip_18,
            this.ToolStrip_19});
            this.ToolStrip_7.Name = "ToolStrip_7";
            this.ToolStrip_7.Size = new System.Drawing.Size(152, 22);
            this.ToolStrip_7.Tag = "0";
            this.ToolStrip_7.Text = "录入员工信息";
            this.ToolStrip_7.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_18
            //
            this.ToolStrip_18.Name = "ToolStrip_18";
            this.ToolStrip_18.Size = new System.Drawing.Size(142, 22);
            this.ToolStrip_18.Tag = "18";
            this.ToolStrip_18.Text = "单个信息录入";
            this.ToolStrip_18.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_19
            //
            this.ToolStrip_19.Enabled = false;
            this.ToolStrip_19.Name = "ToolStrip_19";
            this.ToolStrip_19.Size = new System.Drawing.Size(142, 22);
            this.ToolStrip_19.Tag = "19";
            this.ToolStrip_19.Text = "批量信息录入";
            this.ToolStrip_19.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_8
            //
            this.ToolStrip_8.Name = "ToolStrip_8";
            this.ToolStrip_8.Size = new System.Drawing.Size(152, 22);
            this.ToolStrip_8.Tag = "8";
            this.ToolStrip_8.Text = "所有员工信息";
            this.ToolStrip_8.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_4_0
            //
            this.ToolStrip_4_0.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.ToolStrip_9,
            this.ToolStrip_10,
            this.ToolStrip_11,
            this.ToolStrip_12,
            this.toolStripMenuItem7,
            this.toolStripMenuItem6,
            this.toolStripMenuItem5,
            this.toolStripMenuItem4,
            this.toolStripMenuItem3,
            this.ToolStrip_13,
            this.ToolStrip_14});
            this.ToolStrip_4_0.Name = "ToolStrip_4_0";
            this.ToolStrip_4_0.Size = new System.Drawing.Size(65, 20);
            this.ToolStrip_4_0.Tag = "0";
            this.ToolStrip_4_0.Text = "出租管理";
            //
            // ToolStrip_9
            //
            this.ToolStrip_9.Name = "ToolStrip_9";
            this.ToolStrip_9.Size = new System.Drawing.Size(152, 22);
            this.ToolStrip_9.Tag = "9";
            this.ToolStrip_9.Text = "房型信息设置";
            this.ToolStrip_9.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_10
            //
            this.ToolStrip_10.Enabled = false;
            this.ToolStrip_10.Name = "ToolStrip_10";
            this.ToolStrip_10.Size = new System.Drawing.Size(152, 22);
            this.ToolStrip_10.Tag = "10";
            this.ToolStrip_10.Text = "楼层设置";
            this.ToolStrip_10.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_11
            //
            this.ToolStrip_11.Name = "ToolStrip_11";
            this.ToolStrip_11.Size = new System.Drawing.Size(152, 22);
            this.ToolStrip_11.Tag = "11";
            this.ToolStrip_11.Text = "幢/座设置";
            this.ToolStrip_11.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_12
            //
            this.ToolStrip_12.Enabled = false;
            this.ToolStrip_12.Name = "ToolStrip_12";
            this.ToolStrip_12.Size = new System.Drawing.Size(152, 22);
            this.ToolStrip_12.Tag = "12";
            this.ToolStrip_12.Text = "装修程度设置";
            this.ToolStrip_12.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // toolStripMenuItem7
            //
            this.toolStripMenuItem7.Name = "toolStripMenuItem7";
            this.toolStripMenuItem7.Size = new System.Drawing.Size(152, 22);
            this.toolStripMenuItem7.Tag = "13";
            this.toolStripMenuItem7.Text = "朝向设置";
            this.toolStripMenuItem7.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // toolStripMenuItem6
            //
            this.toolStripMenuItem6.Enabled = false;
            this.toolStripMenuItem6.Name = "toolStripMenuItem6";
            this.toolStripMenuItem6.Size = new System.Drawing.Size(152, 22);
            this.toolStripMenuItem6.Tag = "12";
            this.toolStripMenuItem6.Text = "装修程度设置";
            this.toolStripMenuItem6.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // toolStripMenuItem5
            //
            this.toolStripMenuItem5.Name = "toolStripMenuItem5";
            this.toolStripMenuItem5.Size = new System.Drawing.Size(152, 22);
            this.toolStripMenuItem5.Tag = "11";
            this.toolStripMenuItem5.Text = "幢/座设置";
            this.toolStripMenuItem5.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // toolStripMenuItem4
            //
            this.toolStripMenuItem4.Enabled = false;
            this.toolStripMenuItem4.Name = "toolStripMenuItem4";
            this.toolStripMenuItem4.Size = new System.Drawing.Size(152, 22);
            this.toolStripMenuItem4.Tag = "10";
            this.toolStripMenuItem4.Text = "楼层设置";
            this.toolStripMenuItem4.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // toolStripMenuItem3
            //
            this.toolStripMenuItem3.Name = "toolStripMenuItem3";
            this.toolStripMenuItem3.Size = new System.Drawing.Size(152, 22);
            this.toolStripMenuItem3.Tag = "9";
            this.toolStripMenuItem3.Text = "房型信息设置";
            this.toolStripMenuItem3.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_13
            //
            this.ToolStrip_13.Name = "ToolStrip_13";
            this.ToolStrip_13.Size = new System.Drawing.Size(152, 22);
            this.ToolStrip_13.Tag = "13";
            this.ToolStrip_13.Text = "朝向设置";
            this.ToolStrip_13.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_14
            //
            this.ToolStrip_14.Name = "ToolStrip_14";
            this.ToolStrip_14.Size = new System.Drawing.Size(152, 22);
            this.ToolStrip_14.Tag = "14";
            this.ToolStrip_14.Text = "用途设置";
            this.ToolStrip_14.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_5_0
            //
            this.ToolStrip_5_0.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.ToolStrip_15,
            this.ToolStrip_16});
            this.ToolStrip_5_0.Name = "ToolStrip_5_0";
            this.ToolStrip_5_0.Size = new System.Drawing.Size(65, 20);
            this.ToolStrip_5_0.Tag = "0";
            this.ToolStrip_5_0.Text = "交费管理";
            //
            // ToolStrip_15
            //
            this.ToolStrip_15.Name = "ToolStrip_15";
            this.ToolStrip_15.Size = new System.Drawing.Size(152, 22);
            this.ToolStrip_15.Tag = "15";
            this.ToolStrip_15.Text = "收费设置";
            this.ToolStrip_15.Visible = false;
            this.ToolStrip_15.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_16
            //
            this.ToolStrip_16.Name = "ToolStrip_16";
            this.ToolStrip_16.Size = new System.Drawing.Size(152, 22);
            this.ToolStrip_16.Tag = "16";
            this.ToolStrip_16.Text = "收费记录";
            this.ToolStrip_16.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_6_0
            //
            this.ToolStrip_6_0.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.ToolStrip_17});
            this.ToolStrip_6_0.Name = "ToolStrip_6_0";
            this.ToolStrip_6_0.Size = new System.Drawing.Size(65, 20);
            this.ToolStrip_6_0.Tag = "0";
            this.ToolStrip_6_0.Text = "业务统计";
            //
            // ToolStrip_17
            //
            this.ToolStrip_17.Name = "ToolStrip_17";
            this.ToolStrip_17.Size = new System.Drawing.Size(154, 22);
            this.ToolStrip_17.Tag = "17";
            this.ToolStrip_17.Text = "成交业务量统计";
            this.ToolStrip_17.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_7_0
            //
            this.ToolStrip_7_0.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.ToolStrip_21,
            this.ToolStrip_22,
            this.ToolStrip_23,
            this.ToolStrip_24});
            this.ToolStrip_7_0.Name = "ToolStrip_7_0";
            this.ToolStrip_7_0.Size = new System.Drawing.Size(65, 20);
            this.ToolStrip_7_0.Tag = "0";
            this.ToolStrip_7_0.Text = "常用工具";
            //
            // ToolStrip_21
            //
            this.ToolStrip_21.Name = "ToolStrip_21";
            this.ToolStrip_21.Size = new System.Drawing.Size(152, 22);
            this.ToolStrip_21.Tag = "21";
            this.ToolStrip_21.Text = "记事本";
            this.ToolStrip_21.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_22
            //
            this.ToolStrip_22.Name = "ToolStrip_22";
            this.ToolStrip_22.Size = new System.Drawing.Size(152, 22);
            this.ToolStrip_22.Tag = "22";
            this.ToolStrip_22.Text = "记算器";
            this.ToolStrip_22.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_23
            //
            this.ToolStrip_23.Name = "ToolStrip_23";
            this.ToolStrip_23.Size = new System.Drawing.Size(152, 22);
            this.ToolStrip_23.Tag = "23";
            this.ToolStrip_23.Text = "WORD";
            this.ToolStrip_23.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_24
            //
            this.ToolStrip_24.Name = "ToolStrip_24";
            this.ToolStrip_24.Size = new System.Drawing.Size(152, 22);
            this.ToolStrip_24.Tag = "24";
            this.ToolStrip_24.Text = "EXCEL";
            this.ToolStrip_24.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_8_0
            //
            this.ToolStrip_8_0.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.ToolStrip_25,
            this.ToolStrip_26,
            this.ToolStrip_27,
            this.ToolStrip_28,
            this.ToolStrip_29});
            this.ToolStrip_8_0.Name = "ToolStrip_8_0";
            this.ToolStrip_8_0.Size = new System.Drawing.Size(65, 20);
            this.ToolStrip_8_0.Tag = "0";
            this.ToolStrip_8_0.Text = "系统管理";
            //
            // ToolStrip_25
            //
            this.ToolStrip_25.Name = "ToolStrip_25";
            this.ToolStrip_25.Size = new System.Drawing.Size(152, 22);
            this.ToolStrip_25.Tag = "25";
            this.ToolStrip_25.Text = "口令设置";
            this.ToolStrip_25.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_26
            //
            this.ToolStrip_26.Name = "ToolStrip_26";
            this.ToolStrip_26.Size = new System.Drawing.Size(152, 22);
            this.ToolStrip_26.Tag = "26";
            this.ToolStrip_26.Text = "退出系统";
            this.ToolStrip_26.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_27
            //
            this.ToolStrip_27.Name = "ToolStrip_27";
            this.ToolStrip_27.Size = new System.Drawing.Size(152, 22);
            this.ToolStrip_27.Tag = "27";
            this.ToolStrip_27.Text = "数据库备份";
            this.ToolStrip_27.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_28
            //
            this.ToolStrip_28.Name = "ToolStrip_28";
            this.ToolStrip_28.Size = new System.Drawing.Size(152, 22);
            this.ToolStrip_28.Tag = "28";
            this.ToolStrip_28.Text = "数据库恢复";
            this.ToolStrip_28.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_29
            //
            this.ToolStrip_29.Name = "ToolStrip_29";
            this.ToolStrip_29.Size = new System.Drawing.Size(152, 22);
            this.ToolStrip_29.Tag = "29";
            this.ToolStrip_29.Text = "清理无效信息";
            this.ToolStrip_29.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // ToolStrip_9_0
            //
            this.ToolStrip_9_0.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.ToolStrip_30});
            this.ToolStrip_9_0.Name = "ToolStrip_9_0";
            this.ToolStrip_9_0.Size = new System.Drawing.Size(41, 20);
            this.ToolStrip_9_0.Tag = "0";
            this.ToolStrip_9_0.Text = "帮助";
            //
            // ToolStrip_30
            //
            this.ToolStrip_30.Name = "ToolStrip_30";
            this.ToolStrip_30.Size = new System.Drawing.Size(118, 22);
            this.ToolStrip_30.Tag = "30";
            this.ToolStrip_30.Text = "帮助文件";
            this.ToolStrip_30.Click += new System.EventHandler(this.ToolStrip_1_Click);
            //
            // toolStrip1
            //
            this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.toolStripButton1,
            this.toolStripButton2,
            this.toolStripButton3,
            this.toolStripButton4,
            this.toolStripButton5});
            this.toolStrip1.Location = new System.Drawing.Point(0, 24);
            this.toolStrip1.Name = "toolStrip1";
            this.toolStrip1.Size = new System.Drawing.Size(641, 25);
            this.toolStrip1.TabIndex = 4;
            this.toolStrip1.Text = "toolStrip1";
            //
            // toolStripButton1
            //
            this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image")));
            this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton1.Name = "toolStripButton1";
            this.toolStripButton1.Size = new System.Drawing.Size(97, 22);
            this.toolStripButton1.Tag = "1";
            this.toolStripButton1.Text = "求租人员信息";
            this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click);
            //
            // toolStripButton2
            //
            this.toolStripButton2.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton2.Image")));
            this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton2.Name = "toolStripButton2";
            this.toolStripButton2.Size = new System.Drawing.Size(121, 22);
            this.toolStripButton2.Tag = "2";
            this.toolStripButton2.Text = "出租人员信息设置";
            this.toolStripButton2.Click += new System.EventHandler(this.toolStripButton1_Click);
            //
            // toolStripButton3
            //
            this.toolStripButton3.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton3.Image")));
            this.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton3.Name = "toolStripButton3";
            this.toolStripButton3.Size = new System.Drawing.Size(97, 22);
            this.toolStripButton3.Tag = "4";
            this.toolStripButton3.Text = "房源查询设置";
            this.toolStripButton3.Click += new System.EventHandler(this.toolStripButton1_Click);
            //
            // toolStripButton4
            //
            this.toolStripButton4.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton4.Image")));
            this.toolStripButton4.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton4.Name = "toolStripButton4";
            this.toolStripButton4.Size = new System.Drawing.Size(73, 22);
            this.toolStripButton4.Tag = "16";
            this.toolStripButton4.Text = "收费记录";
            this.toolStripButton4.Click += new System.EventHandler(this.toolStripButton1_Click);
            //
            // toolStripButton5
            //
            this.toolStripButton5.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton5.Image")));
            this.toolStripButton5.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton5.Name = "toolStripButton5";
            this.toolStripButton5.Size = new System.Drawing.Size(109, 22);
            this.toolStripButton5.Tag = "17";
            this.toolStripButton5.Text = "成交业务量统计";
            this.toolStripButton5.Click += new System.EventHandler(this.toolStripButton1_Click);
            //
            // panel_Tree
            //
            this.panel_Tree.Controls.Add(this.treeView1);
            this.panel_Tree.Dock = System.Windows.Forms.DockStyle.Left;
            this.panel_Tree.Location = new System.Drawing.Point(0, 49);
            this.panel_Tree.Name = "panel_Tree";
            this.panel_Tree.Size = new System.Drawing.Size(192, 374);
            this.panel_Tree.TabIndex = 5;
            //
            // treeView1
            //
            this.treeView1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.treeView1.Location = new System.Drawing.Point(0, 0);
            this.treeView1.Name = "treeView1";
            this.treeView1.Size = new System.Drawing.Size(192, 374);
            this.treeView1.TabIndex = 8;
            this.treeView1.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseDoubleClick);
            //
            // pictureBox1
            //
            this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.pictureBox1.Image = global::用树型列表动态显示菜单.Properties.Resources._1;
            this.pictureBox1.Location = new System.Drawing.Point(192, 49);
            this.pictureBox1.Name = "pictureBox1";
            this.pictureBox1.Size = new System.Drawing.Size(449, 374);
            this.pictureBox1.TabIndex = 6;
            this.pictureBox1.TabStop = false;
            //
            // Form1
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(641, 423);
            this.Controls.Add(this.pictureBox1);
            this.Controls.Add(this.panel_Tree);
            this.Controls.Add(this.toolStrip1);
            this.Controls.Add(this.menuStrip1);
            this.Name = "Form1";
            this.Text = "用树型列表动态显示菜单";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.menuStrip1.ResumeLayout(false);
            this.menuStrip1.PerformLayout();
            this.toolStrip1.ResumeLayout(false);
            this.toolStrip1.PerformLayout();
            this.panel_Tree.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.MenuStrip menuStrip1;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_1_0;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_1;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_2;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_3;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_2_0;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_4;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_5;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_6;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_3_0;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_7;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_8;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_4_0;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_9;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_10;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_11;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_12;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_13;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_14;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_5_0;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_15;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_16;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_6_0;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_17;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_7_0;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_21;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_22;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_23;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_24;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_8_0;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_25;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_26;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_27;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_28;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_29;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_9_0;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_30;
        private System.Windows.Forms.ToolStrip toolStrip1;
        private System.Windows.Forms.ToolStripButton toolStripButton1;
        private System.Windows.Forms.ToolStripButton toolStripButton2;
        private System.Windows.Forms.ToolStripButton toolStripButton3;
        private System.Windows.Forms.ToolStripButton toolStripButton4;
        private System.Windows.Forms.ToolStripButton toolStripButton5;
        private System.Windows.Forms.Panel panel_Tree;
        private System.Windows.Forms.TreeView treeView1;
        private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
        private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
        private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem7;
        private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem6;
        private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem5;
        private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem4;
        private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem3;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_18;
        private System.Windows.Forms.ToolStripMenuItem ToolStrip_19;
        private System.Windows.Forms.PictureBox pictureBox1;
    }
}

Form1.Designer.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 用树型列表动态显示菜单
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        #region  将MenuStrip控件中的信息添加到TreeView控件中
        /// <summary>
        /// 将MenuStrip控件中的首行命令项添加到TreeView控件中
        /// </summary>
        /// <param treeV="TreeView">TreeView控件</param>
        /// <param MenuS="MenuStrip">MenuStrip控件</param>
        public void GetMenu(TreeView treeV, MenuStrip MenuS)
        {
            bool Var_Bool = true;
            for (int i = 0; i < MenuS.Items.Count; i++) //遍历MenuStrip组件中的一级菜单项
            {
                //将一级菜单项的名称添加到TreeView组件的根节点中,并设置当前节点的子节点newNode1
                TreeNode newNode1 = treeV.Nodes.Add(MenuS.Items[i].Text);
                if (MenuS.Items[i].Enabled == false)//判断当前项是否为可用
                {
                    newNode1.ForeColor = Color.Silver;//改变树节点的字体颜色为不可用色
                    Var_Bool = false;
                }
                else
                {
                    newNode1.ForeColor = Color.Black;//改变树节点的字体颜色为可用色
                    Var_Bool = true;
                }
                newNode1.Tag = 0;//标识,有子项的命令项
                //将当前菜单项的所有相关信息存入到ToolStripDropDownItem对象中
                ToolStripDropDownItem newmenu = (ToolStripDropDownItem)MenuS.Items[i];
                GetCavernMenu(newNode1, newmenu, Var_Bool);//添加多层命令项
            }
        }

        /// <summary>
        /// 将MenuStrip控件中的多层命今项添加到TreeView控件中
        /// </summary>
        /// <param newNodeA="TreeNode">TreeNode对象</param>
        /// <param newmenuA="ToolStripDropDownItem">ToolStripDropDownItem对象</param>
        /// <param BL="bool">标识(是否可用)</param>
        public void GetCavernMenu(TreeNode newNodeA, ToolStripDropDownItem newmenuA, bool BL)
        {
            bool Var_Bool = true;
            if (newmenuA.HasDropDownItems && newmenuA.DropDownItems.Count > 0)
                for (int j = 0; j < newmenuA.DropDownItems.Count; j++)    //遍历二级菜单项
                {
                    //将二级菜单名称添加到TreeView组件的子节点newNode1中,并设置当前节点的子节点newNode2
                    TreeNode newNodeB = newNodeA.Nodes.Add(newmenuA.DropDownItems[j].Text);
                    Var_Bool = true;
                    if (BL == false)//判断当前命令项的上一级命令是否可用
                    {
                        newNodeB.ForeColor = Color.Silver;//设置当前命令项的字体颜色为不可用色
                        newNodeB.Tag = 0;//标识,不显示相应的窗体
                        Var_Bool = false;
                    }
                    else
                    {
                        if (newmenuA.DropDownItems[j].Enabled == false)//判断当前命令项是否为可用
                        {
                            newNodeB.ForeColor = Color.Silver;//设置当前命令项的字体颜色为不可用色
                            newNodeB.Tag = 0;//标识,不显示相应的窗体
                            Var_Bool = false;
                        }
                        else
                        {
                            newNodeA.ForeColor = Color.Black;//设置当前命令项的字体颜色为可用色
                            newNodeB.Tag = int.Parse(newmenuA.DropDownItems[j].Tag.ToString());//标识,显示相应的窗体
                        }
                    }
                    //将当前菜单项的所有相关信息存入到ToolStripDropDownItem对象中
                    ToolStripDropDownItem newmenuB = (ToolStripDropDownItem)newmenuA.DropDownItems[j];
                    if (newmenuB.HasDropDownItems && newmenuA.DropDownItems.Count > 0)//如果当前命令项有子项
                    {
                        newNodeB.Tag = 0;//标识,有子项的命令项
                        GetCavernMenu(newNodeB, newmenuB, Var_Bool);//调用递归方法
                    }
                }
        }
        #endregion

        #region  打开MenuStrip控件或TreeView控件相应的窗体
        /// <summary>
        /// 打开MenuStrip控件或TreeView控件相应的窗体
        /// </summary>
        /// <param n="int">标识</param>
        /// <param FName="string">名称</param>
        public void frm_show(int n, string FName)
        {
            switch (n)//通过标识调用各子窗体
            {
                case 0: break;
                case 1:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 2:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 3:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 4:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 5:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 6:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 7:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 8:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 9:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 10:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 11:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 12:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 13:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 14:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 15:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 16:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 17:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 18:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 19:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 21:
                    {
                        //打开记事本
                        System.Diagnostics.Process.Start("notepad.exe");
                        break;
                    }
                case 22:
                    {
                        //打开计算器
                        System.Diagnostics.Process.Start("calc.exe");
                        break;
                    }
                case 23:
                    {
                        //打开WORD文档
                        System.Diagnostics.Process.Start("WINWORD.EXE");
                        break;
                    }
                case 24:
                    {
                        //打开EXCEL文件
                        System.Diagnostics.Process.Start("EXCEL.EXE");
                        break;
                    }
                case 25:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 26:
                    {
                        if (MessageBox.Show("确认退出系统吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                            Application.Exit();//关闭当前工程
                        break;
                    }
                case 27:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 28:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 29:
                    {
                        Form2 fp = new Form2();//实例化一个窗体
                        fp.Text = FName;//设置窗体的名称
                        fp.ShowDialog();//用模试对话框打开窗体
                        fp.Dispose();//释放窗体的所有资原
                        break;
                    }
                case 30:
                    {
                        //打开帮助对话框
                        MessageBox.Show("\tBuild by Allen\t\n\n\t \n\t    谢谢使用!!");
                        break;
                    }
            }
        }
        #endregion

        private void Form1_Load(object sender, EventArgs e)
        {
            Frm_Logon F_Logon = new Frm_Logon();
            if (F_Logon.ShowDialog() == DialogResult.OK)
            {
                GetMenu(treeView1, menuStrip1);//将menuStrip1控件中的信息添加到treeView1控件中
            }
        }

        private void ToolStrip_1_Click(object sender, EventArgs e)
        {
            frm_show(Convert.ToInt16(((ToolStripMenuItem)sender).Tag.ToString()), ((ToolStripMenuItem)sender).Text);
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            frm_show(Convert.ToInt16(((ToolStripButton)sender).Tag.ToString()), ((ToolStripButton)sender).Text);
        }

        private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            frm_show(Convert.ToInt16(e.Node.Tag.ToString()), e.Node.Text);
        }
    }
}

Form1.cs

namespace 用树型列表动态显示菜单
{
    partial class Form2
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.SuspendLayout();
            //
            // Form2
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(292, 135);
            this.Name = "Form2";
            this.Text = "Form2";
            this.ResumeLayout(false);

        }

        #endregion
    }
}

Form2.Designer.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 用树型列表动态显示菜单
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
    }
}

Form2.cs

namespace 用树型列表动态显示菜单
{
    partial class Frm_Logon
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.textBox2 = new System.Windows.Forms.TextBox();
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.label2 = new System.Windows.Forms.Label();
            this.label1 = new System.Windows.Forms.Label();
            this.button1 = new System.Windows.Forms.Button();
            this.button2 = new System.Windows.Forms.Button();
            this.groupBox1.SuspendLayout();
            this.SuspendLayout();
            //
            // groupBox1
            //
            this.groupBox1.Controls.Add(this.textBox2);
            this.groupBox1.Controls.Add(this.textBox1);
            this.groupBox1.Controls.Add(this.label2);
            this.groupBox1.Controls.Add(this.label1);
            this.groupBox1.Location = new System.Drawing.Point(12, 12);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(223, 100);
            this.groupBox1.TabIndex = 0;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "登录信息";
            //
            // textBox2
            //
            this.textBox2.Location = new System.Drawing.Point(94, 55);
            this.textBox2.Name = "textBox2";
            this.textBox2.PasswordChar = ‘*‘;
            this.textBox2.Size = new System.Drawing.Size(100, 21);
            this.textBox2.TabIndex = 7;
            this.textBox2.Text = "mrsoft";
            //
            // textBox1
            //
            this.textBox1.Location = new System.Drawing.Point(94, 23);
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new System.Drawing.Size(100, 21);
            this.textBox1.TabIndex = 6;
            this.textBox1.Text = "mr";
            //
            // label2
            //
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(27, 61);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(53, 12);
            this.label2.TabIndex = 5;
            this.label2.Text = "密  码:";
            //
            // label1
            //
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(27, 27);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(53, 12);
            this.label1.TabIndex = 4;
            this.label1.Text = "用户名:";
            //
            // button1
            //
            this.button1.Location = new System.Drawing.Point(74, 118);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(75, 23);
            this.button1.TabIndex = 1;
            this.button1.Text = "确定";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            //
            // button2
            //
            this.button2.Location = new System.Drawing.Point(157, 117);
            this.button2.Name = "button2";
            this.button2.Size = new System.Drawing.Size(75, 23);
            this.button2.TabIndex = 2;
            this.button2.Text = "取消";
            this.button2.UseVisualStyleBackColor = true;
            this.button2.Click += new System.EventHandler(this.button2_Click);
            //
            // Frm_Logon
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(244, 152);
            this.Controls.Add(this.button2);
            this.Controls.Add(this.button1);
            this.Controls.Add(this.groupBox1);
            this.Name = "Frm_Logon";
            this.Text = "登录";
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.GroupBox groupBox1;
        private System.Windows.Forms.TextBox textBox2;
        private System.Windows.Forms.TextBox textBox1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.Button button2;
    }
}

Frm_Logon.Designer.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 用树型列表动态显示菜单
{
    public partial class Frm_Logon : Form
    {
        public Frm_Logon()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "mr" && textBox2.Text == "mrsoft")
            {
                DialogResult = DialogResult.OK;//将当前窗体的对话框返回值设为OK
                this.Close();
            }
            else
                MessageBox.Show("用户名或密码错误。");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}

Frm_Logon.cs

时间: 2024-10-10 16:58:30

TreeView控件的应用的相关文章

Win32中TreeView控件的使用方法,类似于资源管理器中文件树形显示方式

首先是头文件,内容如下: #include <tchar.h> #include "..\CommonFiles\CmnHdr.h" #include <Windows.h> #include <WindowsX.h> #include <CommCtrl.h> #include "resource.h" #pragma comment (lib,"comctl32.lib") BOOL InitT

WinForms中TreeView控件的扩展与使用

EXE文件方便大家测试   源码下载 TreeView控件非常的好用,在我的公文系统中,使用TreeView控件选择接收公文的人员,支持单选,可多选 现提取出来,方便大家使用 涉及到的知识点 1:从Xml文件中加载内容显示到TreeView控件中 <?xml version="1.0" encoding="utf-8"?> <根目录> <组 名称="校长" 用户ID="1000"> <

ASP.NET - TreeView控件,只操作最后一级节点

效果: 绑定TreeView控件:http://www.cnblogs.com/KTblog/p/4792302.html 主要功能: 点击节点的时候,只操作最后一级的节点,其他节点跳过不执行代码. 代码: 1 using System; 2 using System.Collections.Generic; 3 using System.Data; 4 using System.Data.SqlClient; 5 using System.Web.UI.WebControls; 6 7 nam

在工作表左侧中添加TreeView控件

开发环境基于VSTO:visual studio 2010,VB .Net,excel 2007,文档级别的定制程序. 需求是在sheet的左侧停靠System.Windows.Forms.TreeView控件,实现类似资源浏览器的效果,另外,tree节点使用自定义的图标,支持复选框. 首先准备好树节点的图标,使用visual studio 2010自带的图标可以省去很多麻烦(在安装目录\Common7\VS2010ImageLibrary).我挑选了4个16x16大小的图标拷贝到vsto工程下

将MenuStrip控件中的信息添加到TreeView控件中【转载】

本文详细介绍怎样将MenuStrip控件中的信息添加到TreeView控件中 首先在WinForm窗体中添加一个MenuStrip控件和TreeView控件,根据个人的爱好把控件布局好后.在窗体的加载事件中(根据自己的情况而定)添加如下的代码: /// <summary>   /// 窗体加载时事件   /// </summary>   /// <param name="sender"></param>   /// <param n

如何:使用TreeView控件实现树结构显示及快速查询

本文主要讲述如何通过使用TreeView控件来实现树结构的显示,以及树节点的快速查找功能.并针对通用树结构的数据结构存储进行一定的分析和设计.通过文本能够了解如何存储层次结构的数据库设计,如何快速使用TreeView控件生产树,以及如何快速查找树节点. 关键词:C# TreeView.树结构存储.树节点查找.层次结构 一.      概述: 树结构(层次结构)在项目的使用中特别常见,在不同项目中使用的控件可能不同(如:在Extjs中使用的是TreePanel控件,WinForm中可能用的是Tre

TreeView控件使用

treeView1.SelectedNode = treeView1.Nodes[0];  //选中当前treeview控件的根节点为当前节点添加子节点:  TreeNode tmp; tmp = new TreeNode("需要添加的内容");  treeView1.SelectedNode.Nodes.Add(tmp);  treeView1.SelectedNode = tmp; 为父节点添加子节点: TreeNode tmp;     tmp = new TreeNode(&q

可视化webpart基础开发——TreeView控件读取文档库中的所有文件夹和文件(递归方法读取)

可视化webpart基础开发——TreeView控件读取文档库中的所有文件夹和文件(递归方法读取) 分类: SharePoint2011-12-23 14:44 1584人阅读 评论(0) 收藏 举报 文档sharepointurl测试stringforms 可视化webpart基础开发——TreeView控件读取文档库中的所有文件夹和文件(递归方法读取) 1.在部署的sharepoint网站中新建一个名为“测试文档库”的文档库,并添加各级的子文件夹和子文件,用于测试 2.在VS2010中新建空

b/s和C/S方法用C#递归方法把数据表加载到treeview控件中

先看一下数据库的结构: 表结构如下所示: Num                   Name                                 fatherNum       BZ 01                      总节点                                      0              ...... 0101                   第一个一级节点                          01