private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)

{

    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;

    }

}

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Big Bear 的頭像
    Big Bear

    Programs Knowledge

    Big Bear 發表在 痞客邦 留言(0) 人氣()