2

i want to change a part of a text in the label to be another color and a little bigger, for example the years to be with blue color, or any other color and to be a little bigger cause i gonna make a lesson and i wanna to retain the year, and the rest to be the same black as it was

            label3.Width = pictureBox1.Width*2-100;
            label3.Top = pictureBox1.Top + pictureBox1.Height-50;
            label3.Left = pictureBox1.Left-75;
            label3.Height = 200;
            label3.Text = "Regele Carol al II-lea(1930-1940) si fiul sau Mihai I(9 ani) cu prilejul " +
                "proclamarii principelui Carol al II-lea, Rege al Romaniei, de catre Parlamewntul " +
                "de la Bucuresti, la 8 Iunie 1930";

            label4.Width = pictureBox2.Width * 2 - 75;
            label4.Top = pictureBox2.Top + pictureBox2.Height - 50;
            label4.Left = pictureBox2.Left - 75;
            label4.Height = 150;
            label4.Text = "Clasa de elevi cu Mihai I ce poarta titlul de: 'Mare Voievod de ALBA IULIA' in 1937, de Craciun 25 XII";
Abdul Asam
  • 57
  • 1
  • 5
  • 1
    Possible duplicate of [Multiple colors in a C# .NET label](https://stackoverflow.com/questions/275836/multiple-colors-in-a-c-sharp-net-label) – Rotem Jan 07 '18 at 11:48

1 Answers1

3

Assuming that you really want different colors and fonts within the same label, I would recommend using a RichTextBox instead of a Label, like also mentioned in Rotem's duplicate proposal. It's quite easy to use:

RichTextBox rtb1 = new RichTextBox();
rtb1.SelectionColor = Color.Red;
rtb1.AppendText("Hello ");
rtb1.SelectionColor = Color.Green;
rtb1.AppendText("World");

Likewise with RichTextBox.SelectionFont...

Edit: for the sake of completeness - here are the changes to make it look/react like a label:

rtb1.BackColor = System.Drawing.SystemColors.Control;
rtb1.BorderStyle = System.Windows.Forms.BorderStyle.None;
rtb1.Enabled = false;
rtb1.Multiline = false;
rtb1.ReadOnly = true;
ViKiNG
  • 1,294
  • 2
  • 19
  • 26
oliver
  • 2,771
  • 15
  • 32