Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 843399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:07:14+00:00 2026-05-15T06:07:14+00:00

I need my program to show different parts of the data contained in a

  • 0

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 😀

EDIT:

private void ViewForm_Load(object sender, EventArgs e)
    {
        this.PopulateListBox(lstG30, "G30", ("Jumpgate List.JG"));
        this.PopulateListBox(lstG31, "G31", ("Jumpgate List.JG"));
        this.PopulateListBox(lstG32, "G32", ("Jumpgate List.JG"));
        this.PopulateListBox(lstG33, "G33", ("Jumpgate List.JG"));
        this.PopulateListBox(lstG34, "G34", ("Jumpgate List.JG"));
        this.PopulateListBox(lstG35, "G35", ("Jumpgate List.JG"));
        this.PopulateListBox(lstG36, "G36", ("Jumpgate List.JG"));
        this.PopulateListBox(lstG37, "G37", ("Jumpgate List.JG"));
        this.PopulateListBox(lstG38, "G38", ("Jumpgate List.JG"));
        this.PopulateListBox(lstG39, "G39", ("Jumpgate List.JG"));
    }

    void PopulateListBox(ListBox lb, string prefix, string textfile)
    {
        string[] filestrings = textfile.Split(Environment.NewLine.ToCharArray());
        foreach(string line in filestrings)
        {
            if (line.StartsWith(prefix))
                lb.Items.Add(line);
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T06:07:15+00:00Added an answer on May 15, 2026 at 6:07 am

    Some semi-pseudocode… A method you would call to populate each listbox. Specify the listbox control, the prefix you want to isolate, and the input file:

    void PopulateListBox(ListBox lb, string prefix, string[] textfile)
    {
        foreach(string line in textfile)
        {
            if (line.StartsWith(prefix))
            lb.Add(line);
        }
    }
    

    EDIT:

    This method handles the file as a single string (rather than expecting a string array):

    void PopulateListBox(ListBox lb, string prefix, string textfile)
    {
        string[] filestrings = textfile.Split(Environment.NewLine.ToCharArray());
        foreach(string line in filestrings)
        {
            if (line.StartsWith(prefix))
            lb.Add(line);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need my program to create and edit a config file, which would contain
I need a program that checks if the difference between all pairs of elements
I need my program to see different colors. Pretty much all I need is
I need a program that reads from multiple files and displays a report based
I'm doing a theatrical performance, and I need a program that can read images
I need to create program that creates a XML schema like below using System.Xml.XmlSchema
I need to view QGraphicsScene in 2 QGraphicsViews with condition that they have different
Quick question: Is it possible to showDialog/Show form from a new thread that has
Is there any program that will scan two code files, compare, and show you
I need to show multiple buttons, but each one must have a different background

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.