Click here to Skip to main content
15,117,095 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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?
Posted

1 solution

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)


You need to manipulate the startIndex and length each word using string functions.
   
v2
Comments
amit_upadhyay 24-Aug-10 7:13am
   
yes but how do i select the word??
Venkatesh Mookkan 24-Aug-10 7:41am
   
I have updated the answer little bit. Comment me if you have any questions

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