Friday, October 30, 2009

RichTextBox - Bold

So I have been working on creating letter editor. I started with a richtextbox then I extended it to inculde some standard functions that I think should have been in there from the start.

for example I added a public property for bold which overrides the default read-only bold property, allowing you to set a value

I'll inculde the code for that ...



Public Property Bold() As Boolean
Get
Return MyBase.SelectionFont.Bold
End Get
Set(ByVal value As Boolean)
Dim TempFont As Font
If value = True Then
If MyBase.SelectionFont.Italic = True Then
If MyBase.SelectionFont.Underline = True Then
If MyBase.SelectionFont.Strikeout = True Then
TempFont = New Font(MyBase.SelectionFont, FontStyle.Bold Or FontStyle.Italic Or FontStyle.Underline Or FontStyle.Strikeout)
Else
TempFont = New Font(MyBase.SelectionFont, FontStyle.Bold Or FontStyle.Italic Or FontStyle.Underline)
End If
Else
If MyBase.SelectionFont.Strikeout = True Then
TempFont = New Font(MyBase.SelectionFont, FontStyle.Bold Or FontStyle.Italic Or FontStyle.Strikeout)
Else
TempFont = New Font(MyBase.SelectionFont, FontStyle.Bold Or FontStyle.Italic)
End If
End If
Else
If MyBase.SelectionFont.Underline = True Then
If MyBase.SelectionFont.Strikeout = True Then
TempFont = New Font(MyBase.SelectionFont, FontStyle.Bold Or FontStyle.Underline Or FontStyle.Strikeout)
Else
TempFont = New Font(MyBase.SelectionFont, FontStyle.Bold Or FontStyle.Underline)
End If
Else
If MyBase.SelectionFont.Strikeout = True Then
TempFont = New Font(MyBase.SelectionFont, FontStyle.Bold Or FontStyle.Strikeout)
Else
TempFont = New Font(MyBase.SelectionFont, FontStyle.Bold)
End If
End If
End If
Else
If MyBase.SelectionFont.Italic = True Then
If MyBase.SelectionFont.Underline = True Then
If MyBase.SelectionFont.Strikeout = True Then
TempFont = New Font(MyBase.SelectionFont, FontStyle.Italic Or FontStyle.Underline Or FontStyle.Strikeout)
Else
TempFont = New Font(MyBase.SelectionFont, FontStyle.Italic Or FontStyle.Underline)
End If
Else
If MyBase.SelectionFont.Strikeout = True Then
TempFont = New Font(MyBase.SelectionFont, FontStyle.Italic Or FontStyle.Strikeout)
Else
TempFont = New Font(MyBase.SelectionFont, FontStyle.Italic)
End If
End If
Else
If MyBase.SelectionFont.Underline = True Then
If MyBase.SelectionFont.Strikeout = True Then
TempFont = New Font(MyBase.SelectionFont, FontStyle.Underline Or FontStyle.Strikeout)
Else
TempFont = New Font(MyBase.SelectionFont, FontStyle.Underline)
End If
Else
If MyBase.SelectionFont.Strikeout = True Then
TempFont = New Font(MyBase.SelectionFont, FontStyle.Strikeout)
Else
TempFont = New Font(MyBase.SelectionFont, FontStyle.Regular)
End If
End If
End If
End If

MyBase.SelectionFont = TempFont
End Set
End Property

No comments: