简体   繁体   English

如何在列表视图上添加项目(每列)

[英]How to add items on listview (each column)

I tried using this code to add items on ListView but clearly I only add one column on each rows although I have 10 columns.我尝试使用此代码在 ListView 上添加项目,但显然我只在每行上添加一列,尽管我有 10 列。 Here's my code:这是我的代码:

ListView1.Items.Add(firstname.Text)
ListView1.Items.Add(middlename.Text)
ListView1.Items.Add(lastname.Text)
ListView1.Items.Add(gender.Text)
ListView1.Items.Add(age.Text)
ListView1.Items.Add(address.Text)
ListView1.Items.Add(lrnNumber.Text)
ListView1.Items.Add(formerschool.Text)
ListView1.Items.Add(strandcourse.Text)
ListView1.Items.Add(contact.Text)
ListView1.Items.Add(birthdate.Text)

You should create the object ListViewItem at first:您应该首先创建对象ListViewItem

ListViewItem item = new ListViewItem(new []{"1","2","3","4"});
listView1.Items.Add(item);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM