Click here to Skip to main content
15,892,059 members
Home / Discussions / C#
   

C#

 
AnswerRe: Winforms Update form label from a class library Pin
BillWoodruff10-Jan-12 6:17
professionalBillWoodruff10-Jan-12 6:17 
QuestionHow to access the control of a form from diffrent form? Pin
Paramu19739-Jan-12 4:08
Paramu19739-Jan-12 4:08 
AnswerRe: How to access the control of a form from diffrent form? Pin
Ravi Bhavnani9-Jan-12 4:15
professionalRavi Bhavnani9-Jan-12 4:15 
AnswerRe: How to access the control of a form from diffrent form? Pin
RexGrammer9-Jan-12 8:09
RexGrammer9-Jan-12 8:09 
AnswerRe: How to access the control of a form from diffrent form? Pin
DaveyM699-Jan-12 9:07
professionalDaveyM699-Jan-12 9:07 
AnswerRe: How to access the control of a form from diffrent form? Pin
BillWoodruff10-Jan-12 6:55
professionalBillWoodruff10-Jan-12 6:55 
GeneralRe: How to access the control of a form from diffrent form? Pin
Paramu197310-Jan-12 19:03
Paramu197310-Jan-12 19:03 
Questiondesktop sharing Pin
Member 38923438-Jan-12 21:24
Member 38923438-Jan-12 21:24 
AnswerRe: desktop sharing Pin
RexGrammer9-Jan-12 1:56
RexGrammer9-Jan-12 1:56 
AnswerRe: desktop sharing Pin
Ravi Bhavnani9-Jan-12 2:06
professionalRavi Bhavnani9-Jan-12 2:06 
QuestionReading an image from an array of data on disk Pin
Subterranean8-Jan-12 1:36
Subterranean8-Jan-12 1:36 
AnswerRe: Reading an image from an array of data on disk Pin
Luc Pattyn8-Jan-12 1:46
sitebuilderLuc Pattyn8-Jan-12 1:46 
GeneralRe: Reading an image from an array of data on disk Pin
harold aptroot8-Jan-12 4:06
harold aptroot8-Jan-12 4:06 
AnswerRe: Reading an image from an array of data on disk Pin
Luc Pattyn8-Jan-12 4:46
sitebuilderLuc Pattyn8-Jan-12 4:46 
GeneralRe: Reading an image from an array of data on disk Pin
harold aptroot8-Jan-12 4:55
harold aptroot8-Jan-12 4:55 
AnswerRe: Reading an image from an array of data on disk Pin
Luc Pattyn8-Jan-12 5:08
sitebuilderLuc Pattyn8-Jan-12 5:08 
GeneralRe: Reading an image from an array of data on disk Pin
harold aptroot8-Jan-12 5:22
harold aptroot8-Jan-12 5:22 
GeneralRe: Reading an image from an array of data on disk Pin
BobJanova9-Jan-12 0:59
BobJanova9-Jan-12 0:59 
QuestionSearch engine for LAN Pin
archies_gall8-Jan-12 0:50
archies_gall8-Jan-12 0:50 
AnswerRe: Search engine for LAN Pin
Richard MacCutchan8-Jan-12 1:16
mveRichard MacCutchan8-Jan-12 1:16 
GeneralRe: Search engine for LAN Pin
archies_gall11-Jan-12 2:04
archies_gall11-Jan-12 2:04 
AnswerRe: Search engine for LAN Pin
Abhinav S8-Jan-12 2:50
Abhinav S8-Jan-12 2:50 
QuestionSearch text in richtextbox wpf c# Pin
moi4117-Jan-12 6:02
moi4117-Jan-12 6:02 
Hello,
I want to search text in a WPF richTextBox. My problem is the text is formatted...

For a normal text I use this:

string wordToSearch = "word";

TextRange tr = new TextRange(this.rtb.Document.ContentStart, 

int startPos = tr.Text.IndexOf(wordToSearch);

this.rtb.Document.ContentEnd);
                        
                       
if (startPos > -1)
{
   int l = this.GetLinesCount(tr.Text, startPosition);
   
  TextPointer startRtb = this.rtb.Document.ContentStart;
  TextPointer start = startRtb.GetPositionAtOffset(startPos + l);
  TextPointer end = start.GetPositionAtOffset(wordToSearch.Length);
  
  this.rtb.Selection.Select(start, end);  
  this.rtb.Selection.ApplyPropertyValue(
                                TextElement.BackgroundProperty, 
                                this.rtb.SelectionBrush);
}

public int GetLinesCount(string str, int startPosition)
{
    int lines = str.Take(startPosition).Count(k => 
                k.Equals((char)13) || k.Equals((char)10));
    return lines + 2;
}


But, for a formatted text (other color for example), I see a difference between my "word" and my "selection" of X characters.

If somebody has an idea?!?
Thank you for help me...
Bye.
AnswerRe: Search text in richtextbox wpf c# Pin
OriginalGriff7-Jan-12 10:11
mveOriginalGriff7-Jan-12 10:11 
GeneralRe: Search text in richtextbox wpf c# Pin
moi4118-Jan-12 23:09
moi4118-Jan-12 23:09 

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.