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!");
}
To save on code size.. why not list them in a file?
EDIT: In response to your comment.. I would just load the files, without extensions.. that would be much easier:
Pass in the path you want to load the XML file names from, perhaps like this:
This will load all the XML file names, without their extensions, giving you the list you require.