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