I am trying to change color and text style within richtextbox for selected text only. but it is not working pl. guide me
my coading is as follows
Dim selStart As Integer = RichTextBox1.SelectionStart
Dim selLength As Integer = RichTextBox1.SelectionLength
Dim FontSize As Integer = Val(combSize.Text) '14
Dim FontName As System.Drawing.Font = CType(combFont.SelectedValue, System.Drawing.Font)
Dim currFont As System.Drawing.Font
Dim fonts As New FontStyle
If Me.RadioButton2.Checked Then
'' fonts = FontStyle.Bold
'' Else
'' fonts = FontStyle.Regular
'' End If
End If
If RichTextBox1.SelectionLength > 0 Then
Dim i As Integer
For i = 0 To selLength - 1
' select 1 char
RichTextBox1.Select(selStart + i, 1)
' get the current font
currFont = RichTextBox1.SelectionFont
' create and assign to the char a new font
' with the new style
RichTextBox1.SelectionFont = New Font(Font.Name, FontSize, currFont.Style)
Next
' reselect the original selection
RichTextBox1.Select(selStart, selLength)
Else
' RichTextBox1.Font = Font(FontName, FontSize, fonts)
''RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont.Name, FontSize, RichTextBox1.SelectionFont.Style)
End If