private void load_treeview()
        { 
            TreeNode guojia = new TreeNode();
            guojia.Text = "国家";
            treeView1.Nodes.Add(guojia);
        }
在load事件中调用该函数效果如图。怎么文本没有显示出来?求解

解决方案 »

  1.   

    代码没有问题。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 WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void Form1_Load(object sender, EventArgs e)
            {
                TreeNode guojia = new TreeNode();
                guojia.Text = "国家";
                treeView1.Nodes.Add(guojia);
            }
        }
    }
    namespace WindowsFormsApplication1
    {
        partial class Form1
        {
            /// <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.treeView1 = new System.Windows.Forms.TreeView();
                this.SuspendLayout();
                // 
                // treeView1
                // 
                this.treeView1.Location = new System.Drawing.Point(35, 23);
                this.treeView1.Name = "treeView1";
                this.treeView1.Size = new System.Drawing.Size(149, 130);
                this.treeView1.TabIndex = 0;
                // 
                // Form1
                // 
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(292, 266);
                this.Controls.Add(this.treeView1);
                this.Name = "Form1";
                this.Text = "Form1";
                this.Load += new System.EventHandler(this.Form1_Load);
                this.ResumeLayout(false);        }        #endregion        private System.Windows.Forms.TreeView treeView1;
        }
    }这是完整的代码
      

  2.   

    你数据绑定要在page_load执行以下!
      

  3.   

    你数据绑定要在page_load执行以下!
      

  4.   

    你数据绑定要在page_load执行以下!