This works like a charm:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
ComboBox c = new ComboBox();
Button b = new Button();
public Form1()
{
InitializeComponent();
b.Text = "New Button";
b.Click += new EventHandler(b_Click);
this.tabPage1.Controls.Add(b);
c.Items.Add("Hello World");
c.Items.Add("My Program");
c.SelectedIndex = 0;
this.tabPage2.Controls.Add(c);
}
void b_Click(object sender, EventArgs e)
{
MessageBox.Show(c.Text.ToString());
}
}
}
If not specified at load time the combox listindex defaults to -1 which is "" (blank) so if you know the exact index at which your default values get displayed in the combo box then set the listindex to that index.
Using the code below the first item in the combobox will get selected at run time.
comboBox1.SelectedIndex = 0 (The first item in the combo box)