I am writing an application in C # (VS Express 2015) and have a combo box that I want to pre-populate with a saved value. I cannot get combobox to use the value I'm trying to set. I created a new project to demonstrate this error.
The main code is given below. Another file declares a LayoutPanel table. The drawComboBox function should add a combo box to the panel with the specified option and row specified.
public Form1()
{
InitializeComponent();
drawComboBox(Options.Blue, 0);
}
public enum Options
{
Unset,
Blue,
Yellow,
Red
};
private void drawComboBox(Options SelectedOption, int row)
{
System.Windows.Forms.ComboBox colorCombo = new System.Windows.Forms.ComboBox();
colorCombo.DataSource = Enum.GetValues(typeof(Options));
colorCombo.Name = "colorCombo";
this.tableLayoutPanel1.Controls.Add(colorCombo, 0, row);
colorCombo.SelectedItem = Options.Yellow;
}
, "", , colorCombo Locals , . , , , , , .
, .