Results 1 to 3 of 3

Thread: Rich Text Fonts

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618

    Rich Text Fonts

    Ok, somethings in .Net they made more complicated and I don't know why....but anyways...

    I am trying to change the font properties via a button push on my Rich Text Box. Basically Bold, Italic and Underlined. I want the button basically to work like an on-off button.

    In VB6, I could just do a:

    rtbTextBlock.SelBold = Not rtbTextBlock.SelBold

    but .Net has made the Bold property of the new SelectedFont a read-only property for some reason. How can I go about doing this in .Net now while maintaining my other font settings? (e.g. If the text is Bold an Italic and I hit the Bold button, I want it to become unBold but still Italic).
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618
    Nevermind, if anybody is interested, I did it:

    If Not rtbChartNote.SelectionFont Is Nothing Then
    Dim currentFont As System.Drawing.Font = rtbChartNote.SelectionFont
    Dim newFontStyle As System.Drawing.FontStyle

    If rtbChartNote.SelectionFont.Bold = True Then
    newFontStyle = currentFont.Style - FontStyle.Bold
    Else
    newFontStyle = currentFont.Style + FontStyle.Bold
    End If

    rtbChartNote.SelectionFont = New Font( _
    currentFont.FontFamily, _
    currentFont.Size, _
    newFontStyle)
    End If
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618
    Hmmm, ok, this doesn't work on partials though. If I have something selected that is half bold, half not, it loses it. Like:

    "This is some text" ... If I select "some text" and hit the Italics key, it all becomes Italic liek this "some text" Instead of "some text"

    But if I have "This is some text" and select "some text" and hit the italics button it works right and becomes "some text"

    **** this is irritating....
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width