组合框错误

时间:2010-12-21 01:30:53

标签: c#

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        ComboBox Combo_Design = new ComboBox();
        Combo_Quality.Items.Add("Best");
        Combo_Quality.Items.Add("Normal");
        Combo_Quality.Items.Add("Draft");

        Combo_Quality.Text = "Best";

        MessageBox.Show(Combo_Quality.Text);

        string selectedItem = Combo_Quality.Items[Combo_Quality.SelectedIndex].ToString(); 

        Combo_Quality.Text = "Normal";

        MessageBox.Show(Combo_Quality.Text);

        string selectedItem2 = Combo_Quality.Items[Combo_Quality.SelectedIndex].ToString(); 

        Combo_Quality.Text = "Draft";

        MessageBox.Show(Combo_Quality.Text);

        string selectedItem3 = Combo_Quality.Items[Combo_Quality.SelectedIndex].ToString(); 



    }

这与组合框有关,我有3个项目可供选择但我希望它是当我选择最好的消息框弹出时让我选择确定,同样适用于普通和draf

1 个答案:

答案 0 :(得分:0)

如果您希望提醒所选文字,您可以:

MessageBox.Show(Combo_Quality.SelectedItem.ToString());

如果你想确认并允许用户取消他的选择,请查看以下问题: How to prevent/cancel a combobox's value change in c#?