How to Clear a SelectedItem of AutoCompleteBox using C# i'm using this it's working for all controls except autocompletebox
void clear()
{
//This loop takes all controls from the form1 - make sure your form name as newInvoice otherwise change it as per your form name
foreach (var controls in newReceiveItemView.GeneralGridLayout.Children)
{
//Clear all textbox values
if (controls is TextBox)
((TextBox)controls).Text = "";
//clear all check boxes
if (controls is CheckBox)
((CheckBox)controls).IsChecked = false;
//Clear all RadComboBox
if (controls is RadComboBox)
((RadComboBox)controls).SelectedItem = null;
//Clear all RadAutoCompleteBox
if (controls is RadAutoCompleteBox)
((RadAutoCompleteBox)controls).SelectedItem = null;// this is not working selectedItem is not Clearing
//((RadComboBox)controls).SelectedIndex = -1;
//Clear all radio buttons
if (controls is RadMaskedTextBox)
((RadMaskedTextBox)controls).Value = "";
}
}
void clear()
{
//This loop takes all controls from the form1 - make sure your form name as newInvoice otherwise change it as per your form name
foreach (var controls in newReceiveItemView.GeneralGridLayout.Children)
{
//Clear all textbox values
if (controls is TextBox)
((TextBox)controls).Text = "";
//clear all check boxes
if (controls is CheckBox)
((CheckBox)controls).IsChecked = false;
//Clear all RadComboBox
if (controls is RadComboBox)
((RadComboBox)controls).SelectedItem = null;
//Clear all RadAutoCompleteBox
if (controls is RadAutoCompleteBox)
((RadAutoCompleteBox)controls).SelectedItem = null;// this is not working selectedItem is not Clearing
//((RadComboBox)controls).SelectedIndex = -1;
//Clear all radio buttons
if (controls is RadMaskedTextBox)
((RadMaskedTextBox)controls).Value = "";
}
}