New to Telerik UI for WinForms? Download free 30-day trial

DropDownStyle

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.

Figure 1: DropDown

WinForms RadDropDownList DropDown

Figure 2: DropDownList

WinForms RadDropDownList DropDownList

Setting DropDownStyle


this.radDropDownList1.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDown;

Me.radDropDownList1.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDown

When RadDropDownList is set to RadDropDownStyle.DropDownList one can control if an image will be displayed in the editor:

Image in Editor

this.radDropDownList1.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList;
this.radDropDownList1.ShowImageInEditorArea = false;

Me.radDropDownList1.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList
Me.radDropDownList1.ShowImageInEditorArea = False

User Defined Values

This section describes how user defined values can be added to the data source populating the items in RadDropDownList. For the purpose we are going to bind the control to a BindingList instance and add the newly created item if the Enter key has been pressed.

Figure 3: Adding User Defined Values

WinForms RadDropDownList Adding User Defined Values

Initial Set Up

private BindingList<string> data;
public DropDownListUserDefinedValues()
{
    InitializeComponent();
    this.data = new BindingList<string>();
    this.data.Add("Sofia");
    this.data.Add("New York");
    this.data.Add("Delhi");
    this.data.Add("Tokyo");
    this.data.Add("Berlin");
    this.data.Add("Moscow");
    this.data.Add("Beijing");
    this.data.Add("Bern");
    this.data.Add("Paris");
    this.data.Add("London");
    this.radDropDownList1.DataSource = this.data;
    this.radDropDownList1.KeyUp += radDropDownList1_KeyUp;
}

Private data As BindingList(Of String)
Public Sub New()
    InitializeComponent()
    Me.data = New BindingList(Of String)()
    Me.data.Add("Sofia")
    Me.data.Add("New York")
    Me.data.Add("Delhi")
    Me.data.Add("Tokyo")
    Me.data.Add("Berlin")
    Me.data.Add("Moscow")
    Me.data.Add("Beijing")
    Me.data.Add("Bern")
    Me.data.Add("Paris")
    Me.data.Add("London")
    Me.RadDropDownList1.DataSource = Me.data
    AddHandler Me.RadDropDownList1.KeyUp, AddressOf RadDropDownList1_KeyUp
End Sub

Now we need to handle the event, perform the required checks and update our data source.

Initial Set Up

private void radDropDownList1_KeyUp(object sender, KeyEventArgs e)
{
    string result = this.radDropDownList1.DropDownListElement.Text;
    if (e.KeyCode == Keys.Enter && !this.data.Contains(result))
    {
        this.data.Insert(0, result);
    }
}

Private Sub RadDropDownList1_KeyUp(sender As Object, e As KeyEventArgs)
    Dim result As String = Me.RadDropDownList1.DropDownListElement.Text
    If e.KeyCode = Keys.Enter AndAlso Not Me.data.Contains(result) Then
        Me.data.Insert(0, result)
    End If
End Sub

See Also

In this article