Read text file into listbox collections
Posted
by Arcadian
on Stack Overflow
See other posts from Stack Overflow
or by Arcadian
Published on 2010-06-09T21:56:05Z
Indexed on
2010/06/09
22:32 UTC
Read the original article
Hit count: 321
Hi, i'm new to C#.
I need my program to show different parts of the data contained in a txt file into different listboxs (which are on different tabs of a form) so that the user can see the particular block of data they are interested in.
the data contained in the txt file looks like this:
G30:39:03:31 JG06
G32:56:36:10 JG04
G31:54:69:52 JG04
G36:32:53:11 JG05
G33:50:05:11 JG06
G39:28:81:21 JG01
G39:22:74:11 JG06
G39:51:44:21 JG03
G39:51:52:22 JG01
G39:51:73:21 JG01
G35:76:24:20 JG06
G35:76:55:11 JG01
G36:31:96:11 JG02
G36:31:96:23 JG02
G36:31:96:41 JG03
though much more of it :)
The separate listboxes will contain only the lines who's first integer pair matches that listbox's name. For example, all the lines that start "G32" will be added to the G32 listbox.
I think the code would start something like:
private void ReadToBox()
{
FileInfo file = new FileInfo("Jumpgate List.JG");
StreamReader objRead = file.OpenText();
while (!objRead.EndOfStream)
but i'm not sure where to start in terms of getting it sorted yet.
Any help? There's some rep in it for you :D
© Stack Overflow or respective owner