0

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.

Is it possible.!!

Hitesh
  • 3,449
  • 8
  • 39
  • 57
  • 1
    Welcome to Stack Overflow. This is not a good way to ask a question here. Did you try _anything_ so far to solve your problem? Show your effort first so people might show theirs. Please read [FAQ], [ask] and [help] as a start.. – Soner Gönül Jul 15 '14 at 07:29
  • have you tried anything ? – H. Mahida Jul 15 '14 at 07:30
  • 1
    Winforms, WPF, or something else? – lc. Jul 15 '14 at 07:30
  • possible duplicate of [Formatting text in WinForm Label](http://stackoverflow.com/questions/11311/formatting-text-in-winform-label) – DIF Jul 15 '14 at 07:58
  • I have an example [here](http://codereview.stackexchange.com/questions/55916/a-lightweight-rich-link-label) – TaW Jul 15 '14 at 08:08

2 Answers2

1

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

H. Mahida
  • 2,356
  • 1
  • 12
  • 23
1

I think answer can be relevant for you: https://stackoverflow.com/a/2527744/3835956

Use a styled RichTextBox instead of a label, select the text and set it to bold.

Community
  • 1
  • 1
Mathias Müller
  • 303
  • 3
  • 12