Add item to Listview control

后端 未结 6 1610
-上瘾入骨i
-上瘾入骨i 2020-11-28 06:31

I have a listview in c# with three columns and the view is details. I need to add a item to each specific column but I am having a hard time with this. I have t

6条回答
  •  旧巷少年郎
    2020-11-28 07:06

    I have done it like this and it seems to work:

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
    
        private void button1_Click(object sender, EventArgs e)
        {
            string[] row = { textBox1.Text, textBox2.Text, textBox3.Text };
            var listViewItem = new ListViewItem(row); 
            listView1.Items.Add(listViewItem);
        }
    }
    

提交回复
热议问题