DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("Display", typeof(string)));

           // Language是一個Class

            dt.Columns.Add(new DataColumn("Id",typeof(Language)));

            dt.Rows.Add(dt.NewRow());

            dt.Rows.Add(dt.NewRow());

            dt.Rows.Add(dt.NewRow());

            dt.Rows.Add(dt.NewRow());

            dt.Rows.Add(dt.NewRow());

            dt.Rows.Add(dt.NewRow());

            dt.Rows[0][0] = "英文";

            dt.Rows[0][1] = Language.English;

            dt.Rows[1][0] = "簡中";

            dt.Rows[1][1] = Language.ChineseSimplified;

            dt.Rows[2][0] = "日";

            dt.Rows[2][1] = Language.Japanese;

            dt.Rows[3][0] = "韓";

            dt.Rows[3][1] = Language.Korean;

            dt.Rows[4][0] = "法";

            dt.Rows[4][1] = Language.French;

            dt.Rows[5][0] = "西班牙";

            dt.Rows[5][1] = Language.French;

            comboBox_Target.DataSource = dt;

            comboBox_Target.DisplayMember = "Display";

            comboBox_Target.ValueMember = "Id";

 

要拿出所選的值,用

(Language)comboBox_Target.SelectedValue

welkingunther 發表在 痞客邦 PIXNET 留言(0) 人氣()