[Implement] ComboBox Item

[Implement] ComboBox Item

{
    ComboBoxItem cbItem = (ComboBoxItem)comboBox1.SelectedItem;
    int selected_id = cbItem.id;//取得ComboBoxItem中的其他參數
}

private void Form1_Load(object sender, EventArgs e)
{
    comboBox1.Items.Add(new ComboBoxItem("a", 1));
    comboBox1.Items.Add(new ComboBoxItem("b", 2));
    this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
}

public class ComboBoxItem
{
    public string value;
    public int id;

    public ComboBoxItem(string _value, int _id)
    {
        this.value = _value;
        this.id = _id;
    }

    public override string ToString()
    {
        return value;
    }
}