[英]How to have text with bold and normal words for same label?
我需要標簽控件的文本同時顯示為粗體和普通字符。
我怎樣才能做到這一點? 任何想法或指針?
謝謝。
編輯:
它是Winform,很抱歉,但我不知道,我為此使用了兩個標簽,但是我只想使用一個標簽。
可能嗎。!!
我做了類似的事情,
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));
}
希望能幫助到你..!!!
注意您可以使用Label Paint事件和Draw我為標簽做的方式
我認為答案可能與您相關: https : //stackoverflow.com/a/2527744/3835956
使用樣式化的RichTextBox代替標簽,選擇文本並將其設置為粗體。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.