Click here to Skip to main content
15,897,371 members
Home / Discussions / C#
   

C#

 
AnswerRe: Select word in richtextbox control Pin
#realJSOP31-Jan-10 2:04
professional#realJSOP31-Jan-10 2:04 
GeneralRe: Select word in richtextbox control Pin
salamonty8631-Jan-10 2:07
salamonty8631-Jan-10 2:07 
GeneralRe: Select word in richtextbox control Pin
OriginalGriff31-Jan-10 2:30
mveOriginalGriff31-Jan-10 2:30 
AnswerRe: Select word in richtextbox control Pin
TheDudeJuan31-Jan-10 2:25
TheDudeJuan31-Jan-10 2:25 
GeneralRe: Select word in richtextbox control Pin
salamonty8631-Jan-10 2:52
salamonty8631-Jan-10 2:52 
GeneralRe: Select word in richtextbox control Pin
Dan Mos31-Jan-10 3:01
Dan Mos31-Jan-10 3:01 
GeneralRe: Select word in richtextbox control Pin
salamonty8631-Jan-10 3:05
salamonty8631-Jan-10 3:05 
GeneralRe: Select word in richtextbox control Pin
Dan Mos31-Jan-10 3:25
Dan Mos31-Jan-10 3:25 
well you need to find the location of the second " " in the text as well as the loacation of the
third " " and then use the
richTextBox1.Select(StartPosition, Endposition);


Here are the steps:
-find the start position of the nth word
-find end postion of the nth word
and select it.

How you do that it's up to you. If it's just spaces that separates your words, then it's quite simple.

id=3 => third word

for(int i=0;i<(id-1);i++)
{
    startPos+=words[i].Length;
}
//now add to the position for the spaces between the numbers
if(id>2) startPos+=(id-2);


for the endPosition:
endPos = startPos+(words[id-1].Length);


Hope it helps
GeneralRe: Select word in richtextbox control Pin
salamonty8631-Jan-10 3:30
salamonty8631-Jan-10 3:30 
GeneralRe: Select word in richtextbox control Pin
Dan Mos31-Jan-10 3:56
Dan Mos31-Jan-10 3:56 
GeneralRe: Select word in richtextbox control Pin
Mycroft Holmes31-Jan-10 16:06
professionalMycroft Holmes31-Jan-10 16:06 
GeneralRe: Select word in richtextbox control Pin
salamonty8631-Jan-10 20:10
salamonty8631-Jan-10 20:10 
QuestionToolStripMenu Pin
jojoba201030-Jan-10 22:35
jojoba201030-Jan-10 22:35 
AnswerRe: ToolStripMenu Pin
Dan Mos30-Jan-10 23:02
Dan Mos30-Jan-10 23:02 
QuestionRe: ToolStripMenu Pin
jojoba201030-Jan-10 23:04
jojoba201030-Jan-10 23:04 
AnswerRe: ToolStripMenu Pin
Dan Mos30-Jan-10 23:18
Dan Mos30-Jan-10 23:18 
QuestionRe: ToolStripMenu Pin
jojoba201030-Jan-10 23:48
jojoba201030-Jan-10 23:48 
AnswerRe: ToolStripMenu Pin
#realJSOP31-Jan-10 0:03
professional#realJSOP31-Jan-10 0:03 
AnswerRe: ToolStripMenu Pin
Mycroft Holmes31-Jan-10 0:05
professionalMycroft Holmes31-Jan-10 0:05 
QuestionRe: ToolStripMenu Pin
jojoba201031-Jan-10 0:30
jojoba201031-Jan-10 0:30 
AnswerRe: ToolStripMenu Pin
#realJSOP31-Jan-10 0:55
professional#realJSOP31-Jan-10 0:55 
AnswerRe: ToolStripMenu Pin
Dan Mos31-Jan-10 0:38
Dan Mos31-Jan-10 0:38 
QuestionRe: ToolStripMenu Pin
jojoba201031-Jan-10 2:16
jojoba201031-Jan-10 2:16 
AnswerRe: ToolStripMenu Pin
Dan Mos31-Jan-10 3:06
Dan Mos31-Jan-10 3:06 
QuestionRe: ToolStripMenu Pin
jojoba201031-Jan-10 3:19
jojoba201031-Jan-10 3:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.