Home All Groups Group Topic Archive Search About

richtextbox selectedtext bold upper .... how to find out

Author
10 Jun 2006 11:05 PM
andreas
When I select a text in a richtextbox to set de selected text in bold,
regular, italic  .. or non I want to do that with one click
Thus I must find out if the selected text is already in bold, regular,
italic......
Is there any code for this
Thanks for any response

Author
11 Jun 2006 8:14 AM
Ahmed
andreas wrote:
> When I select a text in a richtextbox to set de selected text in bold,
> regular, italic  .. or non I want to do that with one click
> Thus I must find out if the selected text is already in bold, regular,
> italic......
> Is there any code for this
> Thanks for any response

if me.RichTextBox1.SelectionFont.Bold then

'do somthing

end if
Author
11 Jun 2006 1:45 PM
andreas
Thanks Ahmed, it works fine but i have still two questions
1)
if I don't want bold, italic ... I set the font to regular but I lose both
when they are there
how set I the text to not bold only or to not italic only
2)
I have taken a code from internet for making the text greater by clicking
and after a little changing it works fine but the original text  become Bold
after wich I don't understand for what reason

Here follows the code

Private Sub mnuGroter_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnuGroter.Click
Const iBasisGrootte As Single = 12

Static FontsizeVergroting As Single = 3

Dim fontsize As Single

Static sGeselecteerd As String

If sGeselecteerd <> rtb.SelectedText Then           'other text

FontsizeVergroting = 3

End If

If rtb.SelectionLength > 0 Then

Dim selStart As Integer = rtb.SelectionStart

Dim selLength As Integer = rtb.SelectionLength

Dim currFont As System.Drawing.Font

fontsize = iBasisGrootte + FontsizeVergroting

Dim i As Integer

For i = 0 To selLength - 1

rtb.Select(selStart + i, 1)

currFont = rtb.SelectionFont

rtb.SelectionFont = New Font(currFont.FontFamily, fontsize, _

currFont.Style)

Next

rtb.Select(selStart, selLength)

FontsizeVergroting = FontsizeVergroting + 2

sGeselecteerd = rtb.SelectedText

End If

End Sub

andreas" <andr***@pandora.be> wrote in message
Show quoteHide quote
news:dfIig.475527$E%2.12533817@phobos.telenet-ops.be...

> When I select a text in a richtextbox to set de selected text in bold,
> regular, italic  .. or non I want to do that with one click
> Thus I must find out if the selected text is already in bold, regular,
> italic......
> Is there any code for this
> Thanks for any response
>
>