DropDownListEditor ComboBox Mode

4 posts, 0 answers
  1. Chris Gethin
    Chris Gethin avatar
    4 posts
    Member since:
    Mar 2010

    Posted 27 May 2012 Link to this post

    Is it possible to set a DropDownListEditor in a PropertyGrid to behave like a ComboBox?

    I have tried setting the DropDownStyle property to RadDropDownStyle.DropDown, which looks as though this should setup this behaviour, but it does not seem to work. It is not possible to enter text even when this has been set.

    Is there an additional step that needs to be taken in order for the dropdown list to allow text entry?

    Thanks,

    Chris
  2. Ivan Petrov
    Admin
    Ivan Petrov avatar
    707 posts

    Posted 30 May 2012 Link to this post

    Hi Chris,

    Thank you for writing.

    You can use the EditorInitialized event to change the drop down editor behavior. Here is a code snippet which demonstrates this:
    private void radPropertyGrid1_EditorInitialized(object sender, PropertyGridItemEditorInitializedEventArgs e)
    {
      if (e.Editor is PropertyGridDropDownListEditor)
      {
        PropertyGridDropDownListEditor editor = e.Editor as PropertyGridDropDownListEditor;
        BaseDropDownListEditorElement element = editor.EditorElement as BaseDropDownListEditorElement;
        element.DropDownStyle = RadDropDownStyle.DropDown;            
      }
    }

    I hope this will be useful. Should you need further assistance, I would be glad to help.
     
    Regards,
    Ivan Petrov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  3. Cesar
    Cesar avatar
    2 posts
    Member since:
    May 2019

    Posted 31 May Link to this post

    How can I populate the dropdown list with items?

    Please in VB.NET

  4. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3217 posts

    Posted 03 Jun Link to this post

    Hello, Cesar,     
     
    In the EditorInitialized event you have access to the BaseDropDownListEditorElement. You can either bind the drop down by setting the DataSource property or add items programmatically to the Items collection. The following help articles demonstrates the two approaches for populating the drop down with data:

    https://docs.telerik.com/devtools/winforms/controls/dropdown-listcontrol-and-checkeddropdownlist/dropdownlist/populating-with-data/design-time
    https://docs.telerik.com/devtools/winforms/controls/dropdown-listcontrol-and-checkeddropdownlist/dropdownlist/populating-with-data/adding-items-programmatically

    I have prepared a sample code snippet for your reference: 

    Sub New()
     
        InitializeComponent()
     
        Me.RadPropertyGrid1.SelectedObject = Me
        AddHandler Me.RadPropertyGrid1.EditorInitialized, AddressOf RadPropertyGrid_EditorInitialized
        AddHandler Me.RadPropertyGrid1.EditorRequired, AddressOf RadPropertyGrid1_EditorRequired
    End Sub
     
    Private Sub RadPropertyGrid_EditorInitialized(sender As Object, e As Telerik.WinControls.UI.PropertyGridItemEditorInitializedEventArgs)
        Dim editor As PropertyGridDropDownListEditor = TryCast(e.Editor, PropertyGridDropDownListEditor)
        If editor IsNot Nothing AndAlso e.Item.Label = "Text" Then
            Dim element As BaseDropDownListEditorElement = TryCast(editor.EditorElement, BaseDropDownListEditorElement)
            For index = 1 To 10
                element.Items.Add("Item"&index)
            Next
        End If
    End Sub
     
    Private Sub RadPropertyGrid1_EditorRequired(sender As Object, e As PropertyGridEditorRequiredEventArgs)
        If e.Item.Label ="Text" Then
            e.EditorType= GetType(PropertyGridDropDownListEditor)
        End If
    End Sub

    I hope this information helps. 

    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.
Back to Top