我想将标签中的部分文字更改为另一种颜色,稍微大一些,例如用蓝色或其他任何颜色的年份,并且要更大一点,因为我要上课我想保留这一年,剩下的就像它一样黑了
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";
答案 0 :(得分:2)
假设您确实需要相同标签中的不同颜色和字体,我建议使用RichTextBox而不是Label,就像Rotem的重复提案中所提到的那样。它很容易使用:
RichTextBox rtb1 = new RichTextBox();
rtb1.SelectionColor = Color.Red;
rtb1.AppendText("Hello ");
rtb1.SelectionColor = Color.Green;
rtb1.AppendText("World");
与RichTextBox.SelectionFont ...
相同编辑:为了完整起见 - 这里有一些变化,使它看起来/反应像标签:
rtb1.BackColor = System.Drawing.SystemColors.Control;
rtb1.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
rtb1.Enabled = false;
rtb1.Multiline = false;
rtb1.ReadOnly = true;