Searching for page number

Stimulsoft Reports.NET discussion
Post Reply
isoft
Posts: 55
Joined: Fri Sep 08, 2006 9:33 am
Location: Croatia

Searching for page number

Post by isoft »

Hi

Is there maybe a way to find a number of page that has specific word in it after the page has been rendered, but before it is shown in print preview. For example, I have a list of peoples names with 10000 names that are spread over 50 pages. What I need to do is find the page number on which the name "John" is.
I need to do it from my application. I think that the code for that should go something like this:

Code: Select all

Dim rpt As New Stimulsoft.Report.StiReport

rpt.Load("Report.mrt")

rpt.RegData(MyDataSet)

rpt.Compile()
rpt.Render()

'The code for finding the page number which has the word in it
I hope there's a way because it would help me extremely.

Thanks!

ivan
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Searching for page number

Post by Vital »

You can use following code:

Code: Select all

Dim stringToFind As String
Dim page As StiPage
Dim PageIndex As Integer
For Each page In rpt.RenderedPages
  Dim component As StiComponent
  For Each component In page.GetComponents
    Dim text As IStiText = TryCast(component,IStiText)
    If (((Not text Is Nothing) AndAlso (Not text.Text Is Nothing)) AndAlso (Not text.Text.Value Is Nothing)) Then
      Dim str As String = text2.Text.Value
      If str = stringToFind Then 'We have find pagenumber      
  Next
Next
isoft
Posts: 55
Joined: Fri Sep 08, 2006 9:33 am
Location: Croatia

Searching for page number

Post by isoft »

Thank You very much for Your reply! You guys are great! It works just like I need it to work.

One more thing. Is there a way to show in the print preview only the pages from 6 to 20 for instance? I need it because when I find the word on a page (lets say page 6), I need to print only that page and the ones that follow.

Thanks again for Your help!
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Searching for page number

Post by Vital »

You can use following code:

Code: Select all

Dim StartIndex As Integer = 6
Dim EndIndex As Integer = Report.RenderedPages.Count - 20

Do While (EndIndex > 0)
  Report.RenderedPages.RemoveAt(Report.RenderedPages.Count - 1)
  EndIndex -= 1
Loop

Do While (StartIndex > 0)
  Report.RenderedPages.RemoveAt(0)
  StartIndex -= 1
Loop
Thank you.
isoft
Posts: 55
Joined: Fri Sep 08, 2006 9:33 am
Location: Croatia

Searching for page number

Post by isoft »

Great! Thanks!
Post Reply