updating a list box
-
hi! as a part of my code i need to read a file and then update the contents in a list box. the file to b read has say 6 items, each in a new line. and i want them to appear the same way in the list box, ie, all the 6 items should appear in a new line each. can someone help me with this? any help will b greatly appreciated! regards lovy.
-
hi! as a part of my code i need to read a file and then update the contents in a list box. the file to b read has say 6 items, each in a new line. and i want them to appear the same way in the list box, ie, all the 6 items should appear in a new line each. can someone help me with this? any help will b greatly appreciated! regards lovy.
I am not sure which language you are looking to find the answer for here so i will give you the best general answer I can. 1. There are thousands of articles online so i would search google for a "how to" on reading from files. Like so: http://www.csharp-station.com/HowTo/ReadWriteTextFile.aspx[^] 2. Then user either the listbox.Items.AddRange or listbox.Items.Add methods to add the items you have read from the file into the listbox. I would personally use the AddRange method. I hope this helps in some way. Also I would move this message into a more relevant forum. This way you will have more chance of getting help in the language you want.
-
I am not sure which language you are looking to find the answer for here so i will give you the best general answer I can. 1. There are thousands of articles online so i would search google for a "how to" on reading from files. Like so: http://www.csharp-station.com/HowTo/ReadWriteTextFile.aspx[^] 2. Then user either the listbox.Items.AddRange or listbox.Items.Add methods to add the items you have read from the file into the listbox. I would personally use the AddRange method. I hope this helps in some way. Also I would move this message into a more relevant forum. This way you will have more chance of getting help in the language you want.
thanks man. well m using VC++ and apparently haven't been able to find any method that does so. again the problem is that I have to read a file and then update the listbox so AddString doesnt work. Reading line wise from a file is tedious and cumbersome. It will be great if you can help me out. thanks regards lovy
-
thanks man. well m using VC++ and apparently haven't been able to find any method that does so. again the problem is that I have to read a file and then update the listbox so AddString doesnt work. Reading line wise from a file is tedious and cumbersome. It will be great if you can help me out. thanks regards lovy
I know very little about VC++ - I would post your question in the specific language forum. Sorry I cant be of much further help.
-
thanks man. well m using VC++ and apparently haven't been able to find any method that does so. again the problem is that I have to read a file and then update the listbox so AddString doesnt work. Reading line wise from a file is tedious and cumbersome. It will be great if you can help me out. thanks regards lovy
Reading a text file is trivial, and to change the string in a listbox, I always use DeleteString and AddString. In fact, if I were getting contents from a text file, I'd probably calle ResetContent, and then AddString to put the text from the file in there. Don't forget to call SetRedraw(FALSE) before doing that so the listbox doesn't cause your users to have a seizure when it flashes and blinks at them during the update. Of course, as already mentioned, you would get better help if you actually posted this question in the appropriate programming forum.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001