Is this possible?
-
In VB.Net Any Text Control (TextBox, RichTextBox, etc...) Is it possible to bold a highlighted/particular text in a control? Thanks...
I did't do that...
-
In VB.Net Any Text Control (TextBox, RichTextBox, etc...) Is it possible to bold a highlighted/particular text in a control? Thanks...
I did't do that...
With a TextBox, you can only set the font and fontweight for the whole string. With the RichTextBox you can set any amount of fonts and font weights to your hearts desire. To set the current selected text to bold, or if it is already bold, set it to normal, you can use something like this :
With Me.rtb
If .SelectionFont IsNot Nothing Then
Dim currentFont As System.Drawing.Font = .SelectionFont
Dim newFontStyle As System.Drawing.FontStyleIf .SelectionFont.Bold = True Then newFontStyle = currentFont.Style - Drawing.FontStyle.Bold Else newFontStyle = currentFont.Style + Drawing.FontStyle.Bold End If .SelectionFont = New Drawing.Font(currentFont.FontFamily, currentFont.Size, newFontStyle) End If End With
Hope this helps
Everyone dies - but not everyone lives
-
In VB.Net Any Text Control (TextBox, RichTextBox, etc...) Is it possible to bold a highlighted/particular text in a control? Thanks...
I did't do that...
-
With a TextBox, you can only set the font and fontweight for the whole string. With the RichTextBox you can set any amount of fonts and font weights to your hearts desire. To set the current selected text to bold, or if it is already bold, set it to normal, you can use something like this :
With Me.rtb
If .SelectionFont IsNot Nothing Then
Dim currentFont As System.Drawing.Font = .SelectionFont
Dim newFontStyle As System.Drawing.FontStyleIf .SelectionFont.Bold = True Then newFontStyle = currentFont.Style - Drawing.FontStyle.Bold Else newFontStyle = currentFont.Style + Drawing.FontStyle.Bold End If .SelectionFont = New Drawing.Font(currentFont.FontFamily, currentFont.Size, newFontStyle) End If End With
Hope this helps
Everyone dies - but not everyone lives
Thanks a lot, your code works perfectly...
I did't do that...
-
Thanks a lot, your code works perfectly...
I did't do that...
Glad to help.
Everyone dies - but not everyone lives