Thanks Herfried, but I am a little newbie.
I want to use this class if it is possible
I use a richtextbox frOm vb.net and when I select words I can click a
menubutton
Can I use the class in the event button_click?
--------------------------------------------------------
Public Class RTBStyles
Inherits RichTextBox
Public Property SelBold() As Boolean
Get
Return SelectionFont.Bold
End Get
Set(ByVal value As Boolean)
SelStyle(FontStyle.Bold, value)
End Set
End Property
Public Property SelUnderline() As Boolean
Get
Return SelectionFont.Underline
End Get
Set(ByVal value As Boolean)
SelStyle(FontStyle.Underline, value)
End Set
End Property
Public Property SelStrikeout() As Boolean
Get
Return SelectionFont.Strikeout
End Get
Set(ByVal value As Boolean)
SelStyle(FontStyle.Strikeout, value)
End Set
End Property
Public Property SelItalic() As Boolean
Get
Return SelectionFont.Italic
End Get
Set(ByVal value As Boolean)
SelStyle(FontStyle.Italic, value)
End Set
End Property
Public Property SelRegular() As Boolean
Get
If ((SelectionFont.Bold = True) Or (SelectionFont.Italic = True) Or
(SelectionFont.Underline = True) Or (SelectionFont.Strikeout = True)) Then
Return False
Else
Return True
End If
End Get
Set(ByVal value As Boolean)
Dim start As Integer = SelectionStart
Dim length As Integer = SelectionLength
For i As Integer = 0 To length - 1
SelectionFont = New Font(SelectionFont.FontFamily, SelectionFont.Size,
FontStyle.Regular)
Next
Me.Select(start, length)
End Set
End Property
Private Sub SelStyle(ByVal _style As FontStyle, ByVal value As Boolean)
Dim start As Integer = SelectionStart
Dim length As Integer = SelectionLength
For i As Integer = 0 To length - 1
Me.Select(start + i, 1)
Dim style As FontStyle
If value = True Then
style = _style
Else
style = FontStyle.Regular
End If
If (SelectionFont.Italic And (FontStyle.Italic <> _style)) Then style =
(style Or FontStyle.Italic)
If (SelectionFont.Strikeout And (FontStyle.Strikeout <> _style)) Then style
= (style Or FontStyle.Strikeout)
If (SelectionFont.Bold And (FontStyle.Bold <> _style)) Then style = (style
Or FontStyle.Bold)
If (SelectionFont.Underline And (FontStyle.Underline <> _style)) Then style
= (style Or FontStyle.Underline)
SelectionFont = New Font(SelectionFont.FontFamily, SelectionFont.Size,
style)
Next
Me.Select(start, length)
End Sub
End Class
------------------------------------------------------------------