This is a migrated thread and some comments may be shown as answers.

DropDownListEditor ComboBox Mode

5 Answers 218 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Chris Gethin
Top achievements
Rank 1
Chris Gethin asked on 27 May 2012, 02:54 PM
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

5 Answers, 1 is accepted

Sort by
0
Ivan Petrov
Telerik team
answered on 30 May 2012, 04:23 PM
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 >>
0
Cesar
Top achievements
Rank 1
answered on 31 May 2019, 02:25 PM

How can I populate the dropdown list with items?

Please in VB.NET

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 03 Jun 2019, 07:34 AM
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.
0
Cesar
Top achievements
Rank 1
answered on 12 Sep 2019, 05:39 PM
Thank you. I took the code sample you sent as base code and it ran well.  Dropdownlisteditor shows all items I configured, but when I select one of them, it displays "nothing" as selected value.  How can I solve this issue?
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 17 Sep 2019, 07:20 AM

 

Hello, Cesar,

The attached gif file illustrates the achieved behavior with the previously suggested solution. I suppose that you are referring to the situation that the selected value from the drop down list is not initialized the next time the editor is activated. To handle this case, you need to set the BaseDropDownListEditorElement.SelectedValue property to the value PropertyGridItem after adding the items in the BaseDropDownListEditorElement:
    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
            Dim propertyItem As PropertyGridItem = TryCast(e.Item, PropertyGridItem)
            element.SelectedValue = propertyItem.Value
        End If

    End Sub

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.
Tags
PropertyGrid
Asked by
Chris Gethin
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Cesar
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or