[英]How to have text with bold and normal words for same label?
I need to have text for my label control which as both bold and normal character. 我需要标签控件的文本同时显示为粗体和普通字符。
How can I do that? 我怎样才能做到这一点? any idea or pointers??
任何想法或指针?
Thanks. 谢谢。
EDIT: 编辑:
It is Winform, and I am sorry but I have no idea, I am using TWO label for this but I want to use only one. 它是Winform,很抱歉,但我不知道,我为此使用了两个标签,但是我只想使用一个标签。
Is it possible.!! 可能吗。!!
I have done something like, 我做了类似的事情,
using (Graphics g = Graphics.FromImage(pictureBox1.Image))
{
Font drawFont = new Font("Arial", 12);
Font drawFontBold = new Font("Arial", 12, FontStyle.Bold);
SolidBrush drawBrush = new SolidBrush(Color.Black);
// find the width of single char using selected fonts
float CharWidth = g.MeasureString("Y", drawFont).Width;
// draw first part of string
g.DrawString("this is normal", drawFont, drawBrush, new RectangleF(350f, 250f, 647, 200));
// now get the total width of words drawn using above settings
float widthFirst = ("this is normal").Length() * CharWidth;
// the width of first part string to start of second part to avoid overlay
g.DrawString(" and this is bold text", drawFontBold, drawBrush, new RectangleF(350f + widthFirst, 250f, 647, 200));
}
Hope it helps..!!! 希望能帮助到你..!!!
NOTE You can use Label Paint event and Draw the way I have done for lable 注意您可以使用Label Paint事件和Draw我为标签做的方式
I think answer can be relevant for you: https://stackoverflow.com/a/2527744/3835956 我认为答案可能与您相关: https : //stackoverflow.com/a/2527744/3835956
Use a styled RichTextBox instead of a label, select the text and set it to bold. 使用样式化的RichTextBox代替标签,选择文本并将其设置为粗体。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.