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

Image in RadToolStripLabelElement

4 Answers 54 Views
Tabstrip (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Haroon
Top achievements
Rank 1
Haroon asked on 18 Sep 2008, 05:36 AM
Hi Telerik Team,
Please do guide me if I can add an image along with Text in RadToolStripLabelElement? If yes then please guide how can I?
What a want is to display an image followed by a label at toolstrip (ImageBeforeText )

Regards,
Haroon.

4 Answers, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 19 Sep 2008, 02:50 PM
Hi Haroon,

Thank you for the question.

You could add images to RadToolStripLabelElement by adding an ImagePrimitive to its children collection. Please, review the code-block below:
 
private void Form1_Load(object sender, EventArgs e) 
    ImagePrimitive imagePrimitive = new ImagePrimitive(); 
    imagePrimitive.Image = Image.FromFile("c:\\asterisk.jpg"); 
 
    this.radToolStripLabelElement1.Children.Add(imagePrimitive); 

Note that you have to choose an image with appropriate size.


Best wishes,
Martin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Haroon
Top achievements
Rank 1
answered on 22 Sep 2008, 04:42 AM
Hi Martin Vasilev,
Thank you for your quick reply I tried the code, it works fine. But the problem I observed is that the image always overlaps the text of the label. can you please help me in this regard.

P.S. Please do accept my apologies for posting the question about RadToolStrip in RadTabStrip section, as I just noticed my mistake.

Regards,
Haroon.
0
Accepted
Martin Vasilev
Telerik team
answered on 24 Sep 2008, 07:45 AM
Hi Haroon,

Thank you for getting back to me.

If you want to have a control over the image-text relation you have to use ImageAndTextLayoutPanel. I have extended the previous example code to more complex solution that handle this:
 
private void Form1_Load(object sender, EventArgs e) 
    ImageAndTextLayoutPanel imageAndTextLayoutPanel = new ImageAndTextLayoutPanel(); 
    imageAndTextLayoutPanel.TextImageRelation = TextImageRelation.ImageBeforeText; 
     
    ImagePrimitive imagePrimitive = new ImagePrimitive(); 
    imagePrimitive.SetValue(ImageAndTextLayoutPanel.IsImagePrimitiveProperty, true); 
    imagePrimitive.Image = Image.FromFile("c:\\asterisk.jpg"); 
 
    TextPrimitive textPrimitive = new TextPrimitive(); 
    textPrimitive.SetValue(ImageAndTextLayoutPanel.IsTextPrimitiveProperty, true); 
    textPrimitive.Text = "Asterisk"
 
    imageAndTextLayoutPanel.Children.Add(imagePrimitive); 
    imageAndTextLayoutPanel.Children.Add(textPrimitive); 
 
    //remove old TextPrimitive 
    this.radToolStripLabelElement1.Children.RemoveAt(0); 
     
    this.radToolStripLabelElement1.Children.Add(imageAndTextLayoutPanel); 

I hope this suits to your scenario. If you need additional assistance, do not hesitate to contact me again.

Sincerely yours,
Martin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Haroon
Top achievements
Rank 1
answered on 24 Sep 2008, 08:23 AM
Hi Martin Vasilev,
Thank you for your reply. Telerik support is always been great (2 Thumbs up)

Sincerely yours,
Haroon.
Tags
Tabstrip (obsolete as of Q2 2010)
Asked by
Haroon
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Haroon
Top achievements
Rank 1
Share this question
or