在vb.net中使用Tab按钮在RichTextBox中选择单词 [英] select words in a richtextbox with tab button in vb.net
问题描述
我想对我在vb.net中制作的免费的Microsoft字词处理器进行细微调整.
我希望能够使用Tab键在richtextbox中选择单词.就像文本是"hello codeproject成员"一样,当我将焦点放在richtextbox上并第一次按tab时,应选择"hello".然后,当我们再次按下选项卡时,应该选择codeproject,依此类推.
我该怎么做?
我想我们必须使用keydown事件,然后检查选项卡的键码.并且这些单词可以被视为由空格分隔.有帮助吗?
i want to do a small tweak with a free microsoft word processor i have made in vb.net
I want to be able to select words in richtextbox with tab button. Like if the text is "hello codeproject members" and when i put the focus on richtextbox and press tab first time "hello" should be selected. Then when we press tab again codeproject should be selected and so on.
how do i do that??
i suppose we have to use keydown event and then check for tab keycode. And the words could be seen as separated by spaces. Any help?
推荐答案
正如您所说,您需要处理KeyDown事件并捕获Tab的Key.但是,Tab键是用于将焦点设置到下一个选项卡索引控件的默认键.我认为,您需要为其余控件设置e.Handle = true或将IsTabStop = true设置.
使用,
As you said, you need to handle KeyDown event and capture Key of the Tab. But Tab key is a default key for setting focus to next tab indexed control. I think, you need to set e.Handle = true or set IsTabStop = true to rest of your controls.
Use,
richTextBox.Select(startIndex, length)
您需要使用字符串函数来操作startIndex并为每个单词加长.
You need to manipulate the startIndex and length each word using string functions.
这篇关于在vb.net中使用Tab按钮在RichTextBox中选择单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!