Results 1 to 7 of 7
  1. #1
    T0P-CENT's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Posts
    88
    Reputation
    14
    Thanks
    17
    My Mood
    Stressed

    [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
    Last edited by T0P-CENT; 01-13-2011 at 04:55 PM.

  2. #2
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    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]

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  3. #3
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    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 Most complete application MPGH will ever offer - 68%




  4. #4
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    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 Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  5. #5
    T0P-CENT's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Posts
    88
    Reputation
    14
    Thanks
    17
    My Mood
    Stressed
    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

  6. #6
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    I only skimmed the first part of your code, the second was too long and I got bored.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  7. #7
    Blubb1337's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Germany
    Posts
    5,915
    Reputation
    161
    Thanks
    3,108
    Don't we still have a snippet vault?



  8. The Following User Says Thank You to Blubb1337 For This Useful Post:

    NextGen1 (01-14-2011)