|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
vb.net richtextbox selectionstart coloringI am trying to change the color of text that the user sees when they are editing a richtextbox. This is the code I am using in the TextChanged method of RichTextBox control. Dim position As Integer = rtb.SelectionStart rtb.Refresh() rtb.SelectionStart = position rtb.SelectionLength = 1 rtb.SelectionColor = Color.Red This works starting with the 2nd character. The first character typed is not red, but all typed characters after that are. Not sure why. Any ideas ? Thanks, Mark That's because the event is fired only after the use typed the first
character (and for other types subsequently). Just call the TextChanged event handler programmatically first (may be in the form load event). By the way, the same result can be achieved just be setting the ForeColor fo the RTB. HTH. <marf***@yahoo.com> wrote in message news:1155819165.641097.265250@p79g2000cwp.googlegroups.com... I am trying to change the color of text that the user sees when theyHi all, are editing a richtextbox. This is the code I am using in the TextChanged method of RichTextBox control. Dim position As Integer = rtb.SelectionStart rtb.Refresh() rtb.SelectionStart = position rtb.SelectionLength = 1 rtb.SelectionColor = Color.Red This works starting with the 2nd character. The first character typed is not red, but all typed characters after that are. Not sure why. Any ideas ? Thanks, Mark Thanks.
Siva M wrote: Show quoteHide quote > That's because the event is fired only after the use typed the first > character (and for other types subsequently). Just call the TextChanged > event handler programmatically first (may be in the form load event). > > By the way, the same result can be achieved just be setting the ForeColor fo > the RTB. > > HTH. > > <marf***@yahoo.com> wrote in message > news:1155819165.641097.265250@p79g2000cwp.googlegroups.com... > Hi all, > > I am trying to change the color of text that the user sees when they > are editing a richtextbox. This is the code I am using in the > TextChanged method of RichTextBox control. > > Dim position As Integer = rtb.SelectionStart > rtb.Refresh() > rtb.SelectionStart = position > > rtb.SelectionLength = 1 > rtb.SelectionColor = Color.Red > > This works starting with the 2nd character. The first character typed > is not red, but all typed characters after that are. Not sure why. > > > Any ideas ? > > Thanks, > Mark
Drawing a compass
Create New RegistryKey ContextMenu Wait for all ThreadPool workers to complete Representing Related Data within a DataGrid ComboBox Saving input in dropdown Withevents work AddHandler dont? Thread not getting value in named slot dynamic main menu Regular Expression for Integer and Float |
|||||||||||||||||||||||