Richtexbox Question

  • Thread starter Thread starter Simon Whale
  • Start date Start date
S

Simon Whale

Visual Studio 2005 (VB)

Is there a way in richtextbox control to "Automatically" replace characters
or strings after a certain poistion? i.e. after character postion 654
replace all "-" symbols with a "%"?

if so can someone point me to a good example

Many Thanks
Simon Whale
 
Simon Whale said:
Visual Studio 2005 (VB)

Is there a way in richtextbox control to "Automatically" replace
characters or strings after a certain poistion? i.e. after character
postion 654 replace all "-" symbols with a "%"?

if so can someone point me to a good example

Many Thanks
Simon Whale

To be clear, the RTB wouldn't do this, you would do it to the RTB's
contents. What you'd have to do is handle the KeyPress and/or KeyDown events
and in those event handlers, you'd check the length of the string in the
RTB. If it's over your limit (654 in your example), you can then split your
RTB's Text into two strings at the 654 mark and replace the chars as you see
fit in the second string. Then you can concatenate the two strings back
together and replace the contents of the RTB with the new string.

-Scott
 
Back
Top