Padding from left of image inside drop down list

6 posts, 0 answers
  1. Kem
    Kem avatar
    14 posts
    Member since:
    Oct 2010

    Posted 27 Jan 2012 Link to this post

    Hello

    I have a image then text displayed as the selected item of a drop down list. As of now, the image is too close to the left edge of the drop down. I would like to control the distance from the left of all items in my drop down including text and images. How can I accomplish this?

    I am using Q2 Build Winform.
    Thank You
  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 31 Jan 2012 Link to this post

    Hi Kem,

    Thank you for writing.

    If I understand correctly, you would like to have padding on the left side of the items in the drop down popup. If this is the case, you can achieve that by subscribing to the VisualItemFormatting event and set the Padding property of the VisualItem:
    void radDropDownList1_VisualListItemFormatting(object sender, VisualItemFormattingEventArgs args)
    {
        args.VisualItem.Padding = new Padding(5, 0, 0, 0);
    }

    I hope that this information addresses your question. Should you have any other questions, do not hesitate to contact us.
     
    Greetings,
    Stefan
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Kem
    Kem avatar
    14 posts
    Member since:
    Oct 2010

    Posted 31 Jan 2012 Link to this post

    The code works for items displayed when the drop down is expanded. Instead, I would like to align the item(s) in the drop down when it is not exapnded. I attached a screen shot of my drop down (no expanded). You will see that the image does not have any padding on the left edge of the drop down.

    Thank You
  5. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 02 Feb 2012 Link to this post

    Hi Kem,

    Please excuse me for the misunderstanding. You can set the desired padding by setting the Padding property of EditableElement of RadDropDownListElement:
    radDropDownList1.DropDownListElement.EditableElement.Padding = new Padding(10, 0, 0, 0);

    Let me know if you have any other questions.

    Regards,
    Stefan
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

  6. Kem
    Kem avatar
    14 posts
    Member since:
    Oct 2010

    Posted 02 Feb 2012 Link to this post

    That works nicely in code. Is the setting available in a designer? I am using Visual Studio 2010.
  7. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 06 Feb 2012 Link to this post

    Hi Kem,

    Thank you for your reply.

    You can introduce this setting at design time by editing the UI Elements of the control. This option is available in the control's Smart Tag. See the attached image for more information.

    I hope this helps.

    Greetings,
    Stefan
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

Back to Top
UI for WinForms is Visual Studio 2017 Ready