ADD TEXT FROM TEXTBOX TO LISTVIEW COLUMN IN C#

Tanuj Kumar

Total Post:134

Points:940
Posted by  Tanuj Kumar
C# 
C#
 5472  View(s)
Ratings:
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. shreesh chandra shukla

    Post:105

    Points:735
    Re: add text from textbox to listview column in C#

    Solution!

    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");

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!