We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

document.FindAll

Hi,
I'm trying to search through a document using the FindAll method, but it either doesn't seem to find all instances of word (or none at all).

Example:

TextRangesHolder[] foundRanges = document.FindAll("phrase", false, false);

foreach (TextRangesHolder rangeHolder in foundRanges) {

foreach (TextRange range in rangeHolder) {
substituteCodes.Add(range.Text);
debug ++;
}
}

I'm not entirely sure what TextRangesHolder and TextRange are because the documentation is not very clear but in this example the document has 26 instances of "phrase" but FindAll only finds 16.

Is there something I'm doing wrong with FindAll? Or are there any obvious reasons why it might not find all instances of a word?

If TextRangesHolder holds many TextRanges why does FindAll return an array? I'm really quite confused about the TextRange stuff.

Thanks for any help you can give me.

Andy

3 Replies

SK Sarath Kumar G Syncfusion Team May 30, 2007 12:30 AM UTC

Hi Andy,

Thank you for your interest in Syncfusion products.

TextRange:

TextRange is a collection of text, in other words it is the paragraph or the range text.

TextRangeHolder:

TextRangeHolder is a collection of TextRanges. The FindAll returns TextRangeHolder the collection of all text range that has the phrase that is given for replacement.

As per the code snippet provided by you, the number of instances of "phrase" depends on the occurrences of the phrase within a paragraph.(i.e., a paragraph might contain more than one instance of "phrase" which is considered a single occurrence. But, replacing is done to all the occurrences).

Here is the sample program for your reference.

http://websamples.syncfusion.com/samples/DocIO.Windows/F_61563/main.htm

Here is the generated document for your reference.

http://www.syncfusion.com/Support/user/uploads/FindAll_b7a8700d.zip

Please let me know if you face any issues.

Regards,
Sarath


AT Andy Tawse May 30, 2007 09:46 AM UTC

Thanks for that. I think I understand TextRanges now but in the particular document I am searching, it still doesn't find *any* occurrences of a phrase that is definitely in it. My code should do that.

Could I send you through the document in question in private. I can't post it on a public forum.

Thanks.


SK Sarath Kumar G Syncfusion Team May 30, 2007 06:20 PM UTC

Hi Andy,

Thank you for your continued interest in Syncfusion products.

Please create a Direct-Trac Incident with TITLE : [ Forum id (61563) - Title of Forum (document.FindAll) ]. You can post your sample document and code using which the issue is reproduced in that Incident. This will be more helpful for us to investigate further in this issue. Your sample document will be kept secured and will be used only for our internal Testing purpose.

Sorry for the inconvenience caused.

Regards,
Sarath

Loader.
Live Chat Icon For mobile
Up arrow icon