[Help] Setting Text Bold And Current StyleFont

Posts 1–7 of 7 · Page 1 of 1
[Help] Setting Text Bold And Current StyleFont
I know Tittle Isn't Clear
But What Basicly I want For Example When i set the font italic and then click on bold the text will be only bold not bold and italic i tried this code but didn't work
Code:
RichTextBox1.Font = New Font(RichTextbox1.Font , FontStyle.Bold Or RichTextBox1.Font.Style)
and also i tried to make it if the font is italic it set it bold and italic but it is not the point
i know this code works :
Code:
If Bold = False Then
            Bold = True
            Dim Style1 = Nothing
            Dim Style2 = Nothing
            Dim style3 = Nothing
            If Italic = True Then
                Style1 = FontStyle.Italic
            End If
            If Underwear = True Then
                Style2 = FontStyle.Underline
            End If
            If Strikeout = True Then
                style3 = FontStyle.Strikeout
            End If
            TextBoxx1.SelectionFont = New Font(TextBoxx1.Font, Style1 Or Style2 Or style3 Or FontStyle.Bold)
        Else
            Bold = False
            Me.TextBoxx1.SelectionFont = New Font(TextBoxx1.Font, FontStyle.Regular)
            Dim Style4 = Nothing
            Dim style5 = Nothing
            Dim Style6 = Nothing
            If Italic = True Then
                Style4 = FontStyle.Italic
            End If
            If Underwear = True Then
                Style5 = FontStyle.Underline
            End If
            If Strikeout = True Then
                style6 = FontStyle.Strikeout
            End If
            TextBoxx1.SelectionFont = New Font(TextBoxx1.Font, Style4 Or style5 Or Style6)
        End If
Don't use RichTextBox1.Font as the first parameter. That's a font type, not a font name.

RichTextBox1.Font.Name should be used. I.e

[php]
Dim f As New Font(RichTextBox1.Font.Name, 8, FontStyle.Bold Or FontStyle.Underline Or FontStyle.Strikeout Or FontStyle.Italic)
[/php]
If your creating a notepad application , you should use .selectionfont as well, this way you can target which words to bold & italic, not the entire box.

But IDK, I trust jason and didn't actually read much, just you had a font issue.
The only issue was that he was using

Code:
RichTextBox1.Font
For the "family name" parameter of the New Font constructor when it should have been
Code:
RichTextBox1.Font.Name
Other than that his code was correct.
Quote Originally Posted by Jason View Post
The only issue was that he was using

Code:
RichTextBox1.Font
For the "family name" parameter of the New Font constructor when it should have been
Code:
RichTextBox1.Font.Name
Other than that his code was correct.
hmm yes i guess that was wrong but still the main problem isn't fixed but anyway thanks close please
I only skimmed the first part of your code, the second was too long and I got bored.
Don't we still have a snippet vault?
Posts 1–7 of 7 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Talk with us