C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » WPF »

Search a text in WPF RichTextBox & replace its font


Posted Date: 07 Nov 2009      Posted By: Rikzz      Member Level: Bronze     Points: 1   Responses: 1



My application is in WPF(VB.NET)

I will be having one list of Names(lstOfNames)

wen my screen gets displayed i will be havin one paragraph inside the RICHTEXTBOX(System.Windows.Controls.RichTextBox)
<RichTextBox Height="50" Name="rtb" Width="212" Margin="139,37,127,37" />

Now wat i need to do is if paragraph contains any name dat is in lstOfNames as well then change its fontstyle(either color/background) & then display it in RICHTEXTBOX





Responses

Author: ABitSmart    07 Nov 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

Something like this,



//RichTextBox rtbx = new RichTextBox();
//List<string> lstOfNames = new List<string>();

System.Windows.Documents.TextRange textRnge = new System.Windows.Documents.TextRange(rtbx.Document.ContentStart, rtbx.Document.ContentEnd);

foreach(string name in lstOfNames)
{
if(textRnge.Text.Contains(name))
{
//do your processing
}
}


Kind regards,
ABitSmart
DNS Web-master, DNS MVM
My blog
Thoughts.exe



Post Reply
You must Sign In to post a response.
Next : How to find the Checkbox Control in WPF DataGrid Control in WPF using C#
Previous : Implementing Remeber Me in WPF
Return to Discussion Forum
Post New Message
Category: WPF

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use