Hello, Daryl,
The RadDropDownList.
DropDownStyle property determines if the text area at the top of the control can be edited. A setting of
DropDown (the default) allows editing and the
DropDownList setting shows the text area as read-only.As it was demonstrated in the previously provided code snippet, the clear button is enabled for the text box in the editable area of
RadDropDownList. If you set the
DropDownStyle property to
DropDownList, note that the text box won't be shown at all. That is why the clear button is not visible.
However, the possible solution that I can suggest is to insert a
LightVisualElement to simulate the clear button:
LightVisualElement clearElement = new LightVisualElement();
public RadForm1()
{
InitializeComponent();
this.radDropDownList1.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList;
clearElement.StretchHorizontally = false;
clearElement.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
clearElement.Alignment = ContentAlignment.MiddleRight;
clearElement.Text = "X";
clearElement.Click += clearElement_Click;
this.radDropDownList1.DropDownListElement.EditableElement.Children.Add(clearElement);
this.radDropDownList1.SelectedIndexChanged += radDropDownList1_SelectedIndexChanged;
}
private void radDropDownList1_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
clearElement.Visibility = this.radDropDownList1.SelectedIndex == -1 ? Telerik.WinControls.ElementVisibility.Collapsed :
Telerik.WinControls.ElementVisibility.Visible;
}
private void clearElement_Click(object sender, EventArgs e)
{
this.radDropDownList1.SelectedIndex = -1;
}
Should you have further questions please let me know.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get
quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers.
Learn More.