Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi.
In order to activate a button in my program I need to read a selected text from a richtextbox and to check if that selection is between "<" and ">".
Example: if selection is "123456" and if the previous character is "<" and the following character is ">" (so the entire text is something like ..<123456>..) then the button will be checked. Otherwise, the checked property of the button needs to be False.
How do I do that? Thanks
Posted
Comments
Rajesh Anuhya 28-Oct-10 8:33am    
No Effort
Toli Cuturicu 28-Oct-10 12:11pm    
Fake answer from OP:
The button that I need is like the BOLD button in Word. If the selected text is written with Bold letter, then the "B" button is checked. And vice-versa.
In my program, I have to check the selected string, and if it is between "<" and ">" (these two characters aren't selected), then the button is highlighted (Checked = TRUE) and the program can perform some additional tasks.
If I try to select the text in front of the initially selected text (123456), the SelectionChanged event is launched (once again)... so not a good option.

Regular Expressions are your best friend in this situation. Here[^]

Hook an event for your rich text box like KeyUp and evaluate the string in the text box.
 
Share this answer
 
v3
Why do you make this automatic ?
just check /validate this things on button click.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900