Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends,
Good morning to all...

I will be very thankful to u ,if u give solution for the below question

I am developing window application to edit pdf content.for example I have one textbox field for getting keyword and one richtextbox field for getting paragaph.

if the keyword(ie.,value of textbox) exist in paragraph,we need to highlight the text in paragraph field(ie.,richtextbox).any suggestion for this?
Posted

Hi.Try This Method.If you are working with WPF.

<richtextbox x:name="MainRichTextBox" selectionchanged="MainRichTextBox_SelectionChanged" xmlns:x="#unknown">

and your code behind:

private void MainRichTextBox_SelectionChanged(object sender, RoutedEventArgs e)
{
RichTextBox richTextBox = e.OriginalSource as RichTextBox;
richTextBox.SelectionBrush = Brushes.Yellow;

//for access to your RichTextBox content
TextRange textRange = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);
if (textRange.Text.Contains("TextBox"))
{
//Put your policy code here for changing Foreground color
}
}
I hope this help you.
Good Luck
 
Share this answer
 
v2
Comments
jai_mca 23-Feb-13 2:19am    
thanks ali..i have one doubt.after the text got selected with color,when we double click it the sentence which the word exist need to load in another rtb box.is it possible?which event used for that?
aliwpf 23-Feb-13 2:53am    
you're welcome.but can you obvious your question?
jai_mca 23-Feb-13 2:56am    
i just wanted to select the sentence when i double click highlighted text in rich text box.how can i do ?
 
Share this answer
 
Comments
jai_mca 23-Feb-13 2:20am    
thanks a lot Uma..i have one doubt.after the text got selected with color,when we double click it the sentence which the word exist need to load in another rtb box.is it possible?which event used for that?
uspatel 23-Feb-13 2:29am    
http://stackoverflow.com//questions/10746121/richtextbox-select-line-on-click

try this
jai_mca 23-Feb-13 4:07am    
i just wanted to select the sentence when i double click highlighted text in rich text box.how can i do in double click event??

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