troubleshooting Question

ListView add new row with Textbox text?

Avatar of kvnsdr
kvnsdr asked on
C#
4 Comments1 Solution479 ViewsLast Modified:
I've found many articles about adding an "Item" which is in many cased incorrectly refered to as a 'Row'.

I need to add a 'New Row" to a listview with data from two textboxes.

So far the code I have inserts the data into the listview, but always overwrites the text in the listview top rows.

A row consists of the first left-hand column ('Item')  and another column next to it ('SubItem').

[Code]
 private void btnAddNew_Click(object sender, EventArgs e)
        {            
            listView1.Items.Add(textBox1.Text);
            listView1.Items[0].SubItems.Add(textBox2.Text);
}
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros