private void Form1_Load(object sender, EventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add("标题", typeof(string)); dt.Columns["标题"].ReadOnly = true; for (int i = 0; i < 100; ++i) { DataRow newRow = dt.NewRow(); newRow["标题"] = "标题 - " + i.ToString(); dt.Rows.Add(newRow); } // bind source dataGridView1.DataSource = dt; }
效果图如下