471,354 Members | 1,301 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

writing combobox context to text file

[Newbie Alert]
I have a combobox that populates its items from a text file when its form
loads. I have added to one of my buttons click events some code to add any
entrys that are manually entered to the combo - something along the lines
of:

cboProcess.Items.Add(cboProcess.Text);

This all works fine. What I want to be able to do is give the user an
option to save the contents of the combo box back to the text file, so
that the next time they run the app any manually added entrys are there.
The code I used to read the file uses a Streamreader, I sort of hacked it
together by reading a couple of webpages - (I'm very much a beginner.) Now
I assume I should be using a Streamwriter to write the file back, but I
cant figure out how to iterate through the combobox contents to write it
back, any help greatly appreciated.

Jon

--
"Oh no, not again"
Dec 6 '05 #1
2 4408
StreamWriter OutFile = new StreamWriter("C:\MyFile.txt",false);

foreach(object L in cboProcess.Items)
{
OutFile.WriteLine(L.ToString());
}

OutFile.Close();

Dec 6 '05 #2
On Tue, 06 Dec 2005 17:10:57 -0000, <jo*********@topscene.com> wrote:
StreamWriter OutFile = new StreamWriter("C:\MyFile.txt",false);

foreach(object L in cboProcess.Items)
{
OutFile.WriteLine(L.ToString());
}

OutFile.Close();


Thanks :) Sorry if you all get lots more daft questions from me as time
goes on....

--
"Oh no, not again"
Dec 6 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by RRoberto | last post: by
reply views Thread by dbuchanan | last post: by
3 posts views Thread by amber | last post: by
reply views Thread by Frnak McKenney | last post: by
8 posts views Thread by =?Utf-8?B?RyBIdXN0aXM=?= | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.