Home > DeveloperSection > Forums > add text from textbox to listview column in C#
Tanuj Kumar

Total Post:134

Points:940
Posted on    July-17-2013 3:45 AM

 C# C# 
Ratings:


 1 Reply(s)
 3685  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



shreesh chandra shukla
shreesh chandra shukla

Total Post:105

Points:735
Posted on    July-17-2013 8:25 AM

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


Don't want to miss updates? Please click the below button!

Follow MindStick