Add item to Listview control

后端 未结 6 1613
-上瘾入骨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:11

    • Very Simple

      private void button1_Click(object sender, EventArgs e)
      {
          ListViewItem item = new ListViewItem();
          item.SubItems.Add(textBox2.Text);
          item.SubItems.Add(textBox3.Text);
          item.SubItems.Add(textBox4.Text);
          listView1.Items.Add(item);
          textBox2.Clear();
          textBox3.Clear();
          textBox4.Clear();
      }
      
    • You can also Do this stuff...

          ListViewItem item = new ListViewItem();
          item.SubItems.Add("Santosh");
          item.SubItems.Add("26");
          item.SubItems.Add("India");
      

提交回复
热议问题