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 8368463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:23:45+00:00 2026-06-09T13:23:45+00:00

May I know is there a shorter way to add items to the comboBox?

  • 0

May I know is there a shorter way to add items to the comboBox? Currently I am only adding 20 items which already seems very long, what if I have a 100 items to add into the comboBox?

My code:

private void loadSharePricesComboBox()
{
    comboComSymbol.Items.Add("BARC");
    comboComSymbol.Items.Add("DEB");
    comboComSymbol.Items.Add("DOM");
    comboComSymbol.Items.Add("EZJ");
    comboComSymbol.Items.Add("GFS");
    comboComSymbol.Items.Add("IHG");
    comboComSymbol.Items.Add("JD.");
    comboComSymbol.Items.Add("LAD");
    comboComSymbol.Items.Add("LLOY");
    comboComSymbol.Items.Add("MRW");
    comboComSymbol.Items.Add("NXT");
    comboComSymbol.Items.Add("OCDO");
    comboComSymbol.Items.Add("RBS");
    comboComSymbol.Items.Add("SMWH");
    comboComSymbol.Items.Add("SPD");
    comboComSymbol.Items.Add("STAN");
    comboComSymbol.Items.Add("SYR");
    comboComSymbol.Items.Add("TALK");
    comboComSymbol.Items.Add("TSCO");
    comboComSymbol.Items.Add("WMH");

    comboComSymbol.SelectedIndex = -1;
}

Your help is much appreciated! Thank you. 🙂

Addition code (for the question i asked Simon Whitehead):

private void btnDownloadXML_Click(object sender, EventArgs e)
{
    using (WebClient client = new WebClient())
    {
        client.DownloadFile("http://www.lse.co.uk/chat/" + comboDownloadXML.SelectedItem,
                            @"..\..\sharePriceXML\" + comboDownloadXML.SelectedItem + ".xml");
    }
    MessageBox.Show("Download Completed! File has been placed in the folder sharePriceXML!");
}
  • 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-06-09T13:23:47+00:00Added an answer on June 9, 2026 at 1:23 pm

    To save on code size.. why not list them in a file?

    void loadSharePricesComboBox(string fileName) {
        using (StreamReader sr = new StreamReader(fileName)) {
            while (!sr.EndOfStream) {
                comboComSymbol.Items.Add(sr.ReadLine());
            }
        }
    }
    

    EDIT: In response to your comment.. I would just load the files, without extensions.. that would be much easier:

    void loadSharePricesComboBox(string path) {
        foreach (string file in Directory.GetFiles(path, "*.xml")) {
            comboComSymbol.Items.Add(Path.GetFileNameWithoutExtension(file));
        }
    }
    

    Pass in the path you want to load the XML file names from, perhaps like this:

    loadSharePricesComboBox(@"..\..\sharePriceXML\");
    

    This will load all the XML file names, without their extensions, giving you the list you require.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

May I know is there any way to add two or more time durations
May I know if there is any way to remove non-alphabetical symbols from a
This may be a silly question I don't know. Is there a way to
May I know is there any way to determine parent class from boost::any? #include
May I know is there any plug-in for eclipse with which I can access
may i know if there is any formula for drawing lines? currently i am
as shown above may i know is there a way to check a return
May I know is there a way to find certain synctax of words in
for website that embed flash to capture camera (red5..etc). may i know is there
As you may know, in many occasions, there is a need to flag some

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.