RadListControl with 2 images

4 posts, 1 answers
  1. Franco
    Franco avatar
    27 posts
    Member since:
    Apr 2010

    Posted 05 Aug 2011 Link to this post

    Hello,
    In my software I made a window similar to the toolbox of Visual Studio. Inside it I displayed (in a RadListControl) the various elements that can be used in the program. For each item I display an icon and a name that identify the object.
    Now I was asked to display another image after the object name, so the item in list must be composed of Image-Text-Image.
    Can I do something like this with the RadListControl?
    if I can't, what other control I could use to achieve what I have been asked?

    thanks for the help, bye!

  2. Answer
    Peter
    Admin
    Peter avatar
    1148 posts

    Posted 10 Aug 2011 Link to this post

    Hi Franco,

    Thank you for writing.

    To achieve the desired layout you should insert an ImagePrimitive in the RadListVisualItem. Further, subscribe for the VisualItemFormatting event and set appropriate images for all items. For your convenience, this suggestion is implemented in the attached sample project. 

    I hope this helps. Let me know if you have further questions.

    Regards,
    Peter
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Michael
    Michael avatar
    1 posts
    Member since:
    Jan 2012

    Posted 03 Mar 2013 Link to this post

    Nevermind... Can't remove post though...
  5. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 05 Mar 2013 Link to this post

    Hi Michael,

    Thank you for writing back.

    RadDropDownList is virtualized control and a few visual items (for example 5 - 8) represent many logical items. This means that you should clear the image if the Text does not ends with "6":
    if (visualItem.Text.EndsWith("6"))
    {
        ImagePrimitive imagePrimitive = (ImagePrimitive)visualItem.Children[0];
        imagePrimitive.Padding = new Padding(0, 0, 5, 0);
        imagePrimitive.Alignment = ContentAlignment.MiddleRight;
        imagePrimitive.Image = Resources.Icon;
    }
    else
    {
        ImagePrimitive imagePrimitive = (ImagePrimitive)visualItem.Children[0];
        imagePrimitive.Padding = new Padding(0, 0, 0, 0);
        imagePrimitive.Alignment = ContentAlignment.MiddleRight;
        imagePrimitive.Image = null;
    }

    I hope this helps. Regards,
    Peter
    the Telerik team
    WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Join us for a FREE webinar to see all the new stuff in action.

    Interested, but can’t attend? Register anyway and we’ll send you the recording.
Back to Top