Save/Open listView w checked items

H

Hareth

how do I save and open checked and unchecked items in my listview to a txt
file

this is kinda what I have in mind but doesnt work; I need it for listview w/
checked items and unchecked




private void btnSave_Click(object sender, System.EventArgs e)

{string File;

File = "aaa";

using (StreamWriter sw = new StreamWriter(File))

try

{foreach (string LItem in listBox1.Items)

{ sw.WriteLine(LItem);}

}

finally

{sw.Close();}

}

}

private void btnLoad_Click(object sender, System.EventArgs e)

{string File;

File = "aaa";

try

{

StreamReader sr = new StreamReader(File);

string line;

while((line=sr.ReadLine())!= null )

listBox1.Items.Add(line);

sr.Close();

}

catch (System.Exception)

{}

}

}
 
G

Guest

create a class that will encapsulate the information and extract it from/to
the ListView. then serialize it
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top