The program compiles correctly but nothing is displayed in the box.
What am I doing wrong?
It is adding it to your combobox drop down options, but you won't see it in the combobox's textbox until you (the user) select one of the items you've added from the drop-down options, which then makes it the selected item.
If you programatically want it to display a given field from the list you have loaded, you need to look at ComboBox.DisplayMember or at ComboBox.SelectedIndex.
Use ComboBox.DisplayMember ... don't short cut it. That way you know that what is being displayed is actually in the in the ComboBox's list of items and the word/string you want displayed.
public partial class Form1 : Form
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
It is no more than a window with a combobox in it.
I have tried this code on two different machines and with c# 2008 but the combobox is still empty!
I guess you have to use another method for adding items. Please note, you can add items to your combobox when "SelectedIndexChanged" occurs. But before your combobox has not any items and index can't be changed.....
As far as i know my code, @Rogachev's code and buster2209's later paste of method works! it adds items to a drop down box, i just cant understand! try this though i put together a little program using some of my methods and Rogachev's populate method (hope you dont mind!) download the zip file and run the solution or the application under RELEASE! i hope it helps and if not reply on this thread!
Also if inside the zip file there is a blank file open that with your zip opener to!
Hope this helps
public class GrossmontBank
//class variables (global - accessible throughout this class)
//scanner object to be used throughout
private static Scanner input = new Scanner(System.in);