开发者

Select multiple words in a text box and track them in C#

开发者 https://www.devze.com 2023-03-12 23:45 出处:网络
Is it possible to select multiple words(for eg: \"The family live in a big house\") and track those selected words?

Is it possible to select multiple words(for eg: "The family live in a big house") and track those selected words?

If possible, how can i do it?

开发者_开发知识库

Edit----

I need to select the words using the mouse and put those selected words in a string array.


What about the MouseUp-Event and the SelectedText-Property?

List<string> _Words;
private void richTextBox1_MouseUp(object sender, MouseEventArgs e)
{
    richTextBox1.SelectionBackColor = Color.DeepPink;
    _Words.Add(richTextBox1.SelectedText);
}


You can use a rich text box and set a highlighting background for each selection (similar to how IE, Firefox, etc will highlight all of the found search terms). You would have to scan the text and insert the highlighting yourself. You wouldn't be able to use the builtin selection properties of a textbox since the text isn't contiguous.

0

精彩评论

暂无评论...
验证码 换一张
取 消