PropertyGridDropDownListEditor with icons

4 posts, 0 answers
  1. Valery
    Valery avatar
    47 posts
    Member since:
    May 2011

    Posted 02 Jan 2018 Link to this post

    I need an PropertyGridDropDownListEditor with icons.
    How can I do that?
  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3047 posts

    Posted 02 Jan 2018 Link to this post

    Hello, Valery, 

    Thank you for writing.  

    In the RadPropertyGrid.EditorInitialized event you can subscribe to the VisualItemFormatting event of the BaseDropDownListEditorElement. Thus, you can assign images to the visual items.



    Here is a sample code snippet which result is illustrated in the attached screenshot below:
    private void radPropertyGrid1_EditorInitialized(object sender, Telerik.WinControls.UI.PropertyGridItemEditorInitializedEventArgs e)
    {
        PropertyGridDropDownListEditor editor = e.Editor as PropertyGridDropDownListEditor;
        if (editor!=null && e.Item.Name=="TextAlign")
        {
            BaseDropDownListEditorElement element = editor.EditorElement as BaseDropDownListEditorElement;
            element.VisualItemFormatting-=element_VisualItemFormatting;
            element.VisualItemFormatting+=element_VisualItemFormatting;
        }
    }
     
    private void element_VisualItemFormatting(object sender, VisualItemFormattingEventArgs args)
    {
        args.VisualItem.Image = GetImageByText(args.VisualItem.Text);
    }
     
    private Image GetImageByText(string align)
    {
        if (align=="Left")
        {
            return Properties.Resources.Format_Align_Left;
        }
        else if (align=="Right")
        {
            return Properties.Resources.Format_Align_Right;
        }
        return Properties.Resources.Format_Align_Center;
    }

    I hope this information helps. Should you have further questions I would be glad to help.
     
    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Valery
    Valery avatar
    47 posts
    Member since:
    May 2011

    Posted 02 Jan 2018 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Thank you. This useful example would be nice to insert into online documentation "PropertyGrid - Editors"
  4. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3047 posts

    Posted 02 Jan 2018 Link to this post

    Hello, Valery, 

    Thank you for writing back. 

    I am glad that the provided code snippet was useful. We will insert a similar example in the relevant articles for RadPropertyGrid in the future improvement of the documentation.

    I hope this information helps. If you have any additional questions, please let me know. 

     Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top