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

A

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
 
A

Ahmed

andreas said:
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
 
A

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top