-
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).
-
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
-
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....