Click here to Skip to main content
15,901,853 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Is it possible to select multiple words(for eg: "The family live in a big house") and track those selected words?
I need to select the words using the mouse and put those selected words in a string array.
If possible, how can i do it?
Posted
Updated 15-Jun-11 4:04am
v2
Comments
Sergey Alexandrovich Kryukov 15-Jun-11 16:47pm    
You did not tag it! WPF, Forms, ASP.NET, what?
--SA

Not possible in a Text box, I'm afraid: it only supports a single, contiguous selection.
 
Share this answer
 
Comments
Thilina C 15-Jun-11 11:31am    
It is possible
Sergey Alexandrovich Kryukov 15-Jun-11 16:51pm    
Did you down-vote this answer because you think it's possible? What you did is not selection. If this is what you wanted, you did not correctly explain it. Not fair!
--SA
Thilina C 16-Jun-11 1:04am    
What I said is,
"I need to select the words using the mouse and put those selected words in a string array."
How else are you selecting words in a text box without highlighting them!!!
Sergey Alexandrovich Kryukov 17-Jun-11 22:33pm    
In TextBox there are no difference between selecting and highlighting (or there is no highlighting if you will), is some other editor there is. You do neither. If it's a solution for you, fine; then the problem is the lack of correctness in the formulation of your own question. You ask about "select" which has its strict sense, but you don't select.
--SA
Sergey Alexandrovich Kryukov 15-Jun-11 16:52pm    
You are right, my 5.
I down-voted OP's own "solution" because it is incorrect.
I suspect OP down-voted this answer by that reason, see my comment.
--SA
Got the answer, and it IS posible

XML
List<string> _Words;
private void richTextBox1_MouseUp(object sender, MouseEventArgs e)
{
    richTextBox1.SelectionBackColor = Color.DeepPink;
    _Words.Add(richTextBox1.SelectedText);
}
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 15-Jun-11 16:46pm    
What you do not NOT selection. Sorry, I voted 1.
--SA
Thilina C 16-Jun-11 1:02am    
I can't understand what you meant by Not selection!!!!
when I execute the code, it selected the words and added it to the LIST....
Hello

Someone called Zhi-Xin Ye posted a way to do this on the MSDN forum a couple of years ago:

http://social.msdn.microsoft.com/forums/en-US/winforms/thread/1d111531-aeaa-472c-baf4-ffd0850d9ce3[^]


Valery.
 
Share this answer
 
Comments
Thilina C 15-Jun-11 10:40am    
This might help. Thanks

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