RichTextBox.selection

  • Thread starter Thread starter Pascal
  • Start date Start date
P

Pascal

IHello
I would like to change the font size, color, name, when I click on a word
and reurn it back to its previous style if i click it again. I try this but
it works only if I make a double click on the word... When i want to select
a piece of word without an apostrophe for example it crashes: What's wrong?
Private Sub RTB_txt_SelectionChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles RTB_txt.SelectionChanged
If RTB_txt.SelectionFont.Name = ("Tahoma") And _
RTB_txt.SelectionFont.Size = "12" And _
RTB_txt.SelectionFont.Style = FontStyle.Bold And _
RTB_txt.SelectionColor = System.Drawing.Color.Red Then

RTB_txt.SelectionFont = New Font("Arial", 11, FontStyle.Regular)
RTB_txt.SelectionColor = System.Drawing.Color.Black
Else

RTB_txt.SelectionFont = New Font("Tahoma", 12, FontStyle.Bold)
RTB_txt.SelectionColor = System.Drawing.Color.Red
RTB_txt.AutoWordSelection = True
End If
End Sub

thanks
pascal
 
Hello
I tried this but nothing happens:

Private Sub RTB_txt_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles RTB_txt.Click
If RTB_txt.SelectionFont.Name = ("Tahoma") And _
RTB_txt.SelectionFont.Size = "12" And _
RTB_txt.SelectionFont.Style = FontStyle.Bold And _
RTB_txt.SelectionColor = System.Drawing.Color.Red Then

RTB_txt.SelectionFont = New Font("Arial", 11, FontStyle.Regular)
RTB_txt.SelectionColor = System.Drawing.Color.Black
Else

RTB_txt.SelectionFont = New Font("Tahoma", 12, FontStyle.Bold)
RTB_txt.SelectionColor = System.Drawing.Color.Red
RTB_txt.AutoWordSelection = True
End If

End Sub
 
Yes it's more complex than I thought before.
I figured than by clicking one time all the word will be selected.... stupid
me!
I understood that I have to drag and move the mouse to see something
happens....... and i discovered if a part of the word is already in arial
etc. and another part is in Tahoma etc. it crashes too arrgh.
I will digg your ideas to see if there is a better solution. thanks
pascal
 
Back
Top