Usuário com melhor resposta
String em negrito

Pergunta
-
Respostas
-
Olá,
Este é um exemplo que fiz para um menustrip e que adaptei para uma label. Se conseguir adaptar para c#
Code SnippetPrivate Sub Label1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Label1.Paint
Label1.Text = String.Empty
Label1.AutoSize = False
e.Graphics.DrawString(strFirst, Label1.Font, Brushes.Black, 0, ItemHeight)
e.Graphics.DrawString(strSecond,
New Font(Label1.Font, FontStyle.Bold), Brushes.Black, sz.Width - ReduceGap, ItemHeight)sz = e.Graphics.MeasureString(strFirst + strSecond, Label1.Font, 400)
Label1.Width = sz.Width
End Sub
-
Todas as Respostas
-
Olá Otto,
Você esta tentando atribuir o texto para um controle Label?
Se for o caso, você terá que criar um novo evento Paint para o Label alterando a formatação texto desenhado.
Essa solução atende, mas é pouco produtiva. Aconselho a usar dois controles Label, um com formatação normal e o outro em negrito.
[ ]
-
Olá,
Este é um exemplo que fiz para um menustrip e que adaptei para uma label. Se conseguir adaptar para c#
Code SnippetPrivate Sub Label1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Label1.Paint
Label1.Text = String.Empty
Label1.AutoSize = False
e.Graphics.DrawString(strFirst, Label1.Font, Brushes.Black, 0, ItemHeight)
e.Graphics.DrawString(strSecond,
New Font(Label1.Font, FontStyle.Bold), Brushes.Black, sz.Width - ReduceGap, ItemHeight)sz = e.Graphics.MeasureString(strFirst + strSecond, Label1.Font, 400)
Label1.Width = sz.Width
End Sub
-