13-06-13, 04:22 PM
تفضل أخي
****
***
**
*
كود :
Private Sub SetBold(ByVal Rbox As RichTextBox)
If Rbox.SelectedText IsNot Nothing Then
Dim CurrFont As Font = Rbox.SelectionFont
Dim BoldStyle As FontStyle
If Rbox.SelectionFont.Bold = True Then
BoldStyle = FontStyle.Regular
Else
BoldStyle = FontStyle.Bold
End If
BoldStyle += CurrFont.Style
Rbox.SelectionFont = New Font(CurrFont.FontFamily, CurrFont.Size, BoldStyle)
End If
End Sub
Private Sub SetItalic(ByVal Rbox As RichTextBox)
If Rbox.SelectedText IsNot Nothing Then
Dim CurrFont As Font = Rbox.SelectionFont
Dim ItalicStyle As FontStyle
If Rbox.SelectionFont.Italic = True Then
ItalicStyle = FontStyle.Regular
Else
ItalicStyle = FontStyle.Italic
End If
ItalicStyle += CurrFont.Style
Rbox.SelectionFont = New Font(CurrFont.FontFamily, CurrFont.Size, ItalicStyle)
End If
End Sub
Private Sub SetUnderline(ByVal Rbox As RichTextBox)
If Rbox.SelectedText IsNot Nothing Then
Dim CurrFont As Font = Rbox.SelectionFont
Dim UnderlineStyle As FontStyle
If Rbox.SelectionFont.Underline = True Then
UnderlineStyle = FontStyle.Regular
Else
UnderlineStyle = FontStyle.Underline
End If
UnderlineStyle += CurrFont.Style
Rbox.SelectionFont = New Font(CurrFont.FontFamily, CurrFont.Size, UnderlineStyle)
End If
End Sub
' كيفية الاستخدام
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SetBold(Me.RichTextBox1)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
SetItalic(Me.RichTextBox1)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
SetUnderline(Me.RichTextBox1)
End Sub****
***
**
*

