How to place background image to the right?

7 posts, 0 answers
  1. Kristoffer
    Kristoffer avatar
    158 posts
    Member since:
    Dec 2012

    Posted 21 Feb 2013 Link to this post

    e.NodeElement.BackgroundImage = myImage;

    See attached image. I want to place this extra icon to the right. Something like "Right-align background image!". Is this possible?
  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 26 Feb 2013 Link to this post

    Hi Kristoffer,

    Thank you for writing.

    To do that, please consider the following code snippet:
    void radTreeView1_NodeFormatting(object sender, TreeNodeFormattingEventArgs e)
    {
        e.NodeElement.ImageLayout = ImageLayout.None;
        e.NodeElement.ImageAlignment = ContentAlignment.MiddleRight;
        e.NodeElement.Image = Image.FromFile(@"C:\Program Files (x86)\Telerik\RadControls for WinForms Q1 2013\Examples\QuickStart\Resources\BUL.png");
    }

    The code above will right align the image on the node.

    I hope this helps.
     

    Regards,
    Stefan
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Kristoffer
    Kristoffer avatar
    158 posts
    Member since:
    Dec 2012

    Posted 26 Feb 2013 Link to this post

    Thanks for your reply.

    The suggested solution does not work. The image (fetched from resources) is always placed in the middle of the entire row.
  5. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 26 Feb 2013 Link to this post

    Please note that I am setting the Image not the BackgroundImage property. Attached you can find a sample project.
     
    Regards,
    Stefan
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  6. Kristoffer
    Kristoffer avatar
    158 posts
    Member since:
    Dec 2012

    Posted 26 Feb 2013 Link to this post

    Thanks. But if you set the image you remove the necessary tree icon.

    I want a left-aligned tree icon, just like in Explorer, plus an "extra note" icon to the right. I realize this is not supported.
  7. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 26 Feb 2013 Link to this post

    It seems that I am missing something. 

    Setting the Image of RadTreeNode sets the image on the left side of the node's text, while setting the image as shown in the NodeFormatting event, will display another image on the very right side of the node (see attached image). Isn't this what you wanted? If not, please let me know what is the exact layout that you need and I will help you achieve it.
     
    Regards,
    Stefan
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  8. Kristoffer
    Kristoffer avatar
    158 posts
    Member since:
    Dec 2012

    Posted 26 Feb 2013 Link to this post

    Ah, now I see. I actually used that image for the icon. Now it works. Thanks!
Back to Top
UI for WinForms is Visual Studio 2017 Ready