- Vb.net richtextbox selected text color how to#
- Vb.net richtextbox selected text color code#
- Vb.net richtextbox selected text color windows#
StrTemp = Mid(SelText, ColorTableEnds + 2, ' Drop into a single string for easier manipulation Sb.Append( " \highlight" & Trim(NewColorIndex.ToString))
' append the color table terminating brace ' append the table entry terminator semi colon Sb.Append( " \blue" & Trim(Value.B.ToString)) Sb.Append( " \green" & Trim(Value.G.ToString)) Sb.Append( " \red" & Trim(Value.R.ToString)) If Mid(strTemp, cycl, 1) = " " Then NewColorIndex += 1 Next ' append the color table without end braceĮnd If ' append the color table entry for the highlight color StrTemp = Mid(SelText, FontTableEnds + 2, determine what color table index number our new color will be
' backup one character so as to exclude the braceĬolorTableEnds -= 1 ' need to count the quantity of semi colons which will '. Sb.Append(Mid(SelText, 1, FontTableEnds + 1))ĬolorTableBegins = InStr(FontTableEnds, SelText, " ") ' add the header and font table to the string accumulator the current default Font table If Me.SelectedText Is Nothing Then Exit Property Dim sb As New StringBuilder() ' use StringBuilder for speed ' and cleanliness Dim SelText As String = Me.SelectedRtf ' move to local string for speed Dim strTemp As String ' used twice for ease of calculating ' internal coordinates Dim FontTableEnds As Integer ' end character of the rtf font table Dim ColorTableBegins As Integer ' beginning of the rtf color table Dim ColorTableEnds As Integer ' end of the rtf color table Dim StartLooking As Integer ' used to walk a string appending chunks Dim HighlightBlockStart As Integer ' used to find "\highlight#" block for ' stripping Dim HighlightBlockEnd As Integer ' used to find "\highlight#" block for ' stripping Dim cycl As Integer ' used in For/Next loops Dim NewColorIndex As Integer = 0 ' new color table index for incoming color ' find the end of the font tableįontTableEnds = InStr( 1, SelText, " }}") SelectedRTF will never be nothing, it will always have at least '. ' First, test SelectedText property NOT SelectedRTF property because '. Public WriteOnly Property SelectionBackColor() As Color
Vb.net richtextbox selected text color code#
' Do not modify it using the code editor.Ĭomponents = New ()
Vb.net richtextbox selected text color windows#
' NOTE: The following procedure is required by the Windows Form Designer ' It can be modified using the Windows Form Designer. If disposing Then If Not (components Is Nothing) ThenĮnd Sub ' Required by the Windows Form Designer Private components As Protected Overloads Overrides Sub Dispose( ByVal disposing As Boolean) ' Add any initialization after the InitializeComponent() call End Sub ' Form overrides dispose to clean up the component list. ' This call is required by the Windows Form Designer. #Region " Windows Form Designer generated code " Rather than repeating, step by step, how this approach works, I heavily Replace “ALL” code in the UserControl Editor with below code.Open the UserControl Code Editor surface.The UserControl design surface will open.From the MainMenu, select Project+AddUserControl.
Vb.net richtextbox selected text color how to#
RichTextBox control understands how to display the \highlight# tag,īut the control does not provide any means of setting the tag. Through our QA cycle yet so use it at your own risk but I think it's prettyĪpparently, there is an RTF tag called \highlight#. It's kind of a kludge, but seems to work OK. Threads asking for such a control and no one every answered. I found many people on the UseNet Groups and discussion We needed a control with background highlighting capabilities, so after looking everywhere, IĮnded up writing one.