This question is locked. New answers and comments are not allowed.
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.
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
0
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:
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.
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.
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
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:
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.
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.
Thank you for your reply. Telerik support is always been great (2 Thumbs up)
Sincerely yours,
Haroon.