Advertise with us

add text from textbox to listview column in C#

Posted by  Tanuj Kumar
 6890  View(s)
Rate this:
Hi developes!

I have a ListView with 3 columns. When I click a button, I want the first text to go to the first column, second text to the second column, and third text to the third column, but it's not working. 

private void button1_Click(object sender, EventArgs e)
    listView1.Column[0].SubItems.Add("my first text")
    listView1.Column[1].SubItems.Add("my second text")
    listView1.Column[2].SubItems.Add("my third text")

please help me

Thanks in advance

  1. Re: add text from textbox to listview column in C#


    Items first before subitems so try:

           listView1.View = View.Details;

           ListViewItem lvwItem = listView1.Items.Add("my first text");

           lvwItem.SubItems.Add("my second text");

           lvwItem.SubItems.Add("my third text");