private void button1_Click(object sender, EventArgs e)
{
ListViewItem lvi = addListView();
this.listView1.Items.Add(lvi);
this.listView1.Refresh();
}
private ListViewItem addListView()
{
ListViewItem lvi = new ListViewItem(this.textBox1.Text);
lvi.SubItems.Add(this.textBox2.Text);
lvi.SubItems.Add(this.textBox3.Text);
lvi.SubItems.Add(this.textBox4.Text);
return lvi;
}
private void Form1_Load(object sender, EventArgs e)
{
this.listView1.Clear();
ColumnHeader header1 = new ColumnHeader();
header1.Text = "学号";
ColumnHeader header2 = new ColumnHeader();
header2.Text = "姓名";
ColumnHeader header3 = new ColumnHeader();
header3.Text = "班级";
ColumnHeader header4 = new ColumnHeader();
header4.Text = "电话";
this.listView1.Columns.AddRange(new ColumnHeader[] { header1, header2, header3, header4 });
this.listView1.GridLines = true;
this.listView1.View = View.Details;
this.listView1.FullRowSelect = true;
}
是否没设置下面的属性?
this.listView1.View = View.Details;