Click here to Skip to main content
15,884,838 members
Home / Discussions / C#
   

C#

 
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 
Questionremote desktop using C# Pin
ruhel azam6-Jan-12 19:56
ruhel azam6-Jan-12 19:56 
AnswerRe: remote desktop using C# PinPopular
Pete O'Hanlon6-Jan-12 23:31
mvePete O'Hanlon6-Jan-12 23:31 
AnswerRe: remote desktop using C# Pin
Abhinav S8-Jan-12 3:01
Abhinav S8-Jan-12 3:01 
QuestionHow to make auto-generated unit tests fail initially? Pin
Jun Du6-Jan-12 10:39
Jun Du6-Jan-12 10:39 
AnswerRe: How to make auto-generated unit tests fail initially? Pin
Not Active6-Jan-12 13:47
mentorNot Active6-Jan-12 13:47 
GeneralRe: How to make auto-generated unit tests fail initially? Pin
OriginalGriff6-Jan-12 23:21
mveOriginalGriff6-Jan-12 23:21 
GeneralRe: How to make auto-generated unit tests fail initially? Pin
Jun Du7-Jan-12 5:29
Jun Du7-Jan-12 5:29 
GeneralRe: How to make auto-generated unit tests fail initially? Pin
Not Active7-Jan-12 5:44
mentorNot Active7-Jan-12 5:44 
GeneralRe: How to make auto-generated unit tests fail initially? Pin
Jun Du7-Jan-12 6:48
Jun Du7-Jan-12 6:48 
GeneralRe: How to make auto-generated unit tests fail initially? Pin
RobCroll8-Jan-12 18:13
RobCroll8-Jan-12 18:13 
GeneralRe: How to make auto-generated unit tests fail initially? Pin
Jun Du9-Jan-12 3:13
Jun Du9-Jan-12 3:13 
AnswerRe: How to make auto-generated unit tests fail initially? Pin
Ravi Bhavnani9-Jan-12 2:12
professionalRavi Bhavnani9-Jan-12 2:12 
GeneralRe: How to make auto-generated unit tests fail initially? Pin
Jun Du9-Jan-12 3:22
Jun Du9-Jan-12 3:22 
GeneralRe: How to make auto-generated unit tests fail initially? Pin
Pete O'Hanlon9-Jan-12 3:52
mvePete O'Hanlon9-Jan-12 3:52 
GeneralRe: How to make auto-generated unit tests fail initially? Pin
Ravi Bhavnani9-Jan-12 4:18
professionalRavi Bhavnani9-Jan-12 4:18 

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.