Hi ,
My program at the moment has 3 textboxes , 1 button and 1 listview.
I've added 3 columns named "Name" "Address" and "Number" to the Listview.
What I have done so far is I can enter text into the 3 textboxes , I click the button and the text I enter appears in the Listview.
But I can't seem to be able to save the text I enter into a text file , what I would also like to do is to be able to enter text into the Listview , re run the program and the text I entered before to be still visible in the Listview , I just can't seem to make the data stick to it at the moment.
If you could steer me in the right direction I would really appreciate it
private void btConfirm_Click(object sender, EventArgs e)
{
String name;
String address;
String number;
name = tbName.Text;
address = tbAddress.Text;
number = tbNumber.Text;
StreamWriter SW = new StreamWriter("Listview.txt");
ListViewItem Item = new ListViewItem();
SW.WriteLine(name);
SW.WriteLine(address);
SW.WriteLine(number);
SW.Flush();
SW.Close();
StreamReader SR = new StreamReader("Listview.txt");
name = SR.ReadLine();
address = SR.ReadLine();
number = SR.ReadLine();
Item.Text = name;
Item.SubItems.Add(address);
Item.SubItems.Add(number);
listView1.Items.Add(Item);
SR.Close();
}