0

我正在使用 Leave 事件Combobox来禁用它并加载一些数据,但是在离开和禁用之后,它会选择Combobox. 我想取消选择文本。

我在用着:

cmbNome.DropDownStyle = ComboBoxStyle.DropDown;    
cmbNome.AutoCompleteMode = AutoCompleteMode.Suggest;    
cmbNome.AutoCompleteSource = AutoCompleteSource.CustomSource;

如果有帮助...

编码:

    private void cmbNome_Leave(object sender, EventArgs e)
    {
        cmbNome.Enabled = false;
        CarregarDados();
        CarregarTelefones();
    }
4

2 回答 2

0

尝试首先取消选择项目,然后将组合框设置为禁用。

cmbNome.SelectedIndex = -1;
cmbNome.Enabled = false;
于 2012-08-10T12:11:07.737 回答
0

在禁用组合框之前尝试设置数据源:

        string[] data = new string[] {
            "Absecon","Abstracta","Abundantia","Academia","Acadiau","Acamas",
            "Ackerman","Ackley","Ackworth","Acomita","Aconcagua","Acton","Acushnet",
            "Acworth","Ada","Ada","Adair","Adairs","Adair","Adak","Adalberta","Adamkrafft",
            "Adams"

        };


        private void comboBox2_Leave(object sender, EventArgs e)
        {
            comboBox2.DataSource = data;
            comboBox2.Enabled = false;
            comboBox2.SelectedIndex = -1;
        }

此代码用数据填充组合;但是,没有选择任何项目并且文本字段为空

编辑:添加示例数据

于 2012-08-10T12:01:37.493 回答