En vb6, il n'y avait aucune difficulté, mais en VB.NET, les propriétés .selectionFont.Bold sont qu'en Lecture, pas en écriture...
RichTextBox1.SelectionFont = New Font(New System.Drawing.FontFamily("Arial"), 8.25, FontStyle.Bold)
Private Sub ChangeSelectedText () Handles btn_B.Click, btn_S.Click, btn_I.click Dim F As New Font(....) With F '... End With RichTextBox1.SelectionFont = F End Sub
Private Sub GrasToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GrasToolStripButton1.Click 'bogue si fontes différentes sont sélectionnées Dim currentFont As System.Drawing.Font = Edit_HTML.SelectionFont Dim newFontStyle As System.Drawing.FontStyle newFontStyle = FontStyle.Bold Edit_HTML.SelectionFont = New Font(currentFont.FontFamily, currentFont.Size, Edit_HTML.SelectionFont.Style Or newFontStyle) End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question' POLICE EN GRAS If Edit_HTML.SelectionLength > 0 Then ' Garde position initiale Dim Depart As Integer = Edit_HTML.SelectionStart Dim LgString As Integer = Edit_HTML.SelectionLength ' Passage à la richtexbox de VB6 qui permet sans effort de mettre les styles sans bug !! With AxRichTextBox1 .TextRTF = Edit_HTML.SelectedRtf .SelStart = 0 .SelLength = .TextRTF.Length .SelBold (Edit_HTML.SelectionFont.Bold False) Edit_HTML.SelectedRtf = Edit_HTML.SelectedRtf.Replace(Edit_HTML.SelectedRtf, .TextRTF) End With ' Supression du retour automatique With Edit_HTML .SelectionStart -= 1 .SelectionLength = 1 .SelectedText = "" End With ' Refait la surbrillance de la selection Edit_HTML.Select(Depart, LgString) End If