I have 2 Forms which named Form1 and Form2. In Form1, a ListView is created which has three column name CusName, CusIC and CusAddress.
When user clicks on the Add Button, a Form2 is pop-up to request the user to fill up the information which consists of Name1, IC1 and Address1.
After user press Save Button in Form2, the values are passing back to Form1 and assign to the ListView. The problem is how to assign value to the ListView, the three values are successfully passed back to Form1 but is unable to assign in ListView.
Thank you!
When user clicks on the Add Button, a Form2 is pop-up to request the user to fill up the information which consists of Name1, IC1 and Address1.
Code:
private void SaveButton_Click(object sender, EventArgs e)
{
string Name = Name1.Text;
string IC = IC1.Text;
string Address = Address1.Text;
Close();
Form1 add = new Form1();
add.addData(Name, IC, Address);
}
Code:
public void addData(string name2, string ic2, string address2)
{
ListViewItem iv = listView1.Items.Add(name2);
iv.SubItems.Add(ic2);
iv.SubItems.Add(address2);
listView1.Items.Add(iv);
}
Comment