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

How to place background image to the right?

6 Answers 191 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Kristoffer
Top achievements
Rank 1
Kristoffer asked on 21 Feb 2013, 04:33 PM
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?

6 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 26 Feb 2013, 11:57 AM
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.
0
Kristoffer
Top achievements
Rank 1
answered on 26 Feb 2013, 12:42 PM
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.
0
Stefan
Telerik team
answered on 26 Feb 2013, 01:16 PM
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.
0
Kristoffer
Top achievements
Rank 1
answered on 26 Feb 2013, 02:10 PM
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.
0
Stefan
Telerik team
answered on 26 Feb 2013, 02:17 PM
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.
0
Kristoffer
Top achievements
Rank 1
answered on 26 Feb 2013, 04:18 PM
Ah, now I see. I actually used that image for the icon. Now it works. Thanks!
Tags
Treeview
Asked by
Kristoffer
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Kristoffer
Top achievements
Rank 1
Share this question
or