RichTextBox-读取相邻字符以进行选择 [英] RichTextBox - read adjacent chars to selection
本文介绍了RichTextBox-读取相邻字符以进行选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨.
为了激活程序中的按钮,我需要从一个富文本框中读取选定的文本,并检查该选择是否在<"之间.和>".
示例:如果选择为"123456",并且前一个字符为<"并且以下字符为>" (因此整个文本类似于..< 123456> ..),然后将选中该按钮.否则,按钮的checked属性需要为False.
我怎么做?在这种情况下,正则表达式是您最好的朋友. 此处 [
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
解决方案
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.
Why do you make this automatic ?
just check /validate this things on button click.
这篇关于RichTextBox-读取相邻字符以进行选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文