tags:

views:

619

answers:

2
+1  Q: 

WPF ComboBox clear

I have Two radio buttons. If i check first radio button The below data will populate in the combobox. After that i will check another radio button, i want to clear the combo box values.

RadioButton Height="29" HorizontalAlignment="Left" Margin="143,193,0,0" Name="rdoEmployee" VerticalAlignment="Top" Width="61" FontSize="20" Checked="rdoEmployee_Checked" GroupName="rdoEmployee

RadioButton FontSize="20" Height="20" Margin="228,193,0,0" Name="rdoPA" VerticalAlignment="Top" HorizontalAlignment="Left" Width="49" Checked="rdoPA_Checked" GroupName="rdoEmployee

  ComboBox HorizontalAlignment="Left" Margin="142,235,0,240" Name="cmbEmpType" Width="200" FontSize="16" 


        EmployeeTypes _ET = new EmployeeTypes();
        DataRowCollection drc = _ET.EmpTypeTable.Rows;
        foreach (DataRow r in drc)
        {
            ComboBoxItem item = new ComboBoxItem();
            item.Tag = r["EmpTypeID"];
            item.Content = r["EmpTypeName"];

            cmbEmpType.Items.Add(item);

            if (cmbEmpType.Items.Count > 0)
            {
                cmbEmpType.SelectedIndex = 0;
            }

        }
A: 

Is it bound? If so, set the bound property to null. If not, set SelectedItem to null.

HTH, Kent

Kent Boogaart
Not working Kent. I bind the combobox from db. When i check the radio buton check, i want to clear the combox box.
Please edit your original question and include XAML and relevant code. Can't help without sufficient info.
Kent Boogaart
+2  A: 

Are you asking for

cmbEmpType.Items.Clear();

This should empty your combo.

gcores
Thank u so much