kvnsdr
asked on
ListView add new row with Textbox text?
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(textBo x1.Text);
listView1.Items[0].SubItem s.Add(text Box2.Text) ;
}
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(textBo
listView1.Items[0].SubItem
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No. You are adding a new one to the end of the list, so that one's OK.
private void btnAddNew_Click(object sender, EventArgs e)
{
listView1.Items.Add(textBo x1.Text);
listView1.Items[listView1. Items.Coun t - 1].SubItems.Add(textBox2.T ext);
}
private void btnAddNew_Click(object sender, EventArgs e)
{
listView1.Items.Add(textBo
listView1.Items[listView1.
}
ASKER
listView1.Items[listView1.