Mettre en gras une partie du texte d'un label

Résolu
ManuAntibes Messages postés 491 Date d'inscription mardi 24 octobre 2000 Statut Membre Dernière intervention 18 novembre 2021 - 21 févr. 2019 à 14:30
ManuAntibes Messages postés 491 Date d'inscription mardi 24 octobre 2000 Statut Membre Dernière intervention 18 novembre 2021 - 22 févr. 2019 à 09:09
Bonjour à tous,

Je voudrais mettre en gras, la deuxième ligne d'un label.

voici mon code.

Dim LabelPlanning As New Label
LabelPlanning.Font = New System.Drawing.Font("Microsoft Sans Serif", 10)
LabelPlanning.Text = "Poste 1"
LabelPlanning.Text += vbNewLine
LabelPlanning.Text += "Pierre"
LabelPlanning.Dock = System.Windows.Forms.DockStyle.Fill
LabelPlanning.TextAlign = HorizontalAlignment.Center
LabelPlanning.BackColor = Color.AliceBlue
Me.TableLayoutPanel1.Controls.Add(LabelPlanning, 2, 2)


je voudrais mettre en gras QUE la ligne du prénom.

Merci à vous

2 réponses

Whismeril Messages postés 19028 Date d'inscription mardi 11 mars 2003 Statut Non membre Dernière intervention 24 avril 2024 656
21 févr. 2019 à 18:31
Bonjour
https://bytes.com/topic/c-sharp/answers/269637-diffrent-fonts-one-label

En C#, que tu peux traduire avec l’un des nombreux convertisseurs en ligne.

D’autre part, pour tes prochaines questions, merci d’utiliser correctement les balises de codes, voir ici https://codes-sources.commentcamarche.net/faq/11288-les-balises-de-code
2
ManuAntibes Messages postés 491 Date d'inscription mardi 24 octobre 2000 Statut Membre Dernière intervention 18 novembre 2021 5
22 févr. 2019 à 09:09
Merci pour la reponse , je vais tester.

Class RTFLabel
    Inherits System.Windows.Forms.RichTextBox

    Public Sub New()
        Me.BackColor = System.Drawing.SystemColors.InactiveBorder
        Me.BorderStyle = System.Windows.Forms.BorderStyle.None
        Me.[ReadOnly] = True
    End Sub

    Public Sub Append(ByVal text As String, ByVal f As Font)
        Dim length As Integer = text.Length
        Dim start As Integer = Me.Text.Length
        Me.AppendText(text)
        Me.[Select](start, length)
        Me.SelectionFont = f
        Me.[Select](0, 0)
    End Sub

    Public Sub Append(ByVal text As String, ByVal fs As FontStyle)
        Dim f As Font = New Font(Me.Font, fs)
        Me.Append(text, f)
    End Sub

    Public Sub AppendRegular(ByVal text As String)
        Me.Append(text, FontStyle.Regular)
    End Sub

    Public Sub AppendBold(ByVal text As String)
        Me.Append(text, FontStyle.Bold)
    End Sub

    Public Sub AppendItalic(ByVal text As String)
        Me.Append(text, FontStyle.Italic)
    End Sub

    Public Sub AppendUnderline(ByVal text As String)
        Me.Append(text, FontStyle.Underline)
    End Sub

    Public Sub AppendStrikeout(ByVal text As String)
        Me.Append(text, FontStyle.Strikeout)
    End Sub
End Class
1
Rejoignez-nous