我刚刚使用VS 2008创建了一个示例项目,其中包含以下代码,它似乎起到了作用:
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 0; i < 10; i++)
{
ListViewItem lvi = new ListViewItem("Test");
listView1.Items.Add(lvi);
}
}
private void button1_Click(object sender, EventArgs e)
{
listView1.CheckBoxes = false;
}
我的listview的属性如下所示:
this.listView1.CheckBoxes = true;
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1});
this.listView1.GridLines = true;
this.listView1.Location = new System.Drawing.Point(12, 12);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(224, 174);
this.listView1.TabIndex = 0;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;