Open Viewer with filled find topic

Stimulsoft Ultimate discussion
Post Reply
User avatar
tpontow
Posts: 206
Joined: Thu Sep 06, 2012 8:46 am
Location: Bonn, Germany

Open Viewer with filled find topic

Post by tpontow »

Hello,

is it possible to open a report with viewer where the find toolbar is shown (CTRL +F) and the textbox with find topic is filled out already and the search is started? So i can have a searched report with highlighted lines at startup time.

Thanks and regards
Thorsten Pontow
Thorsten Pontow

It is easier to write an incorrect program than to understand a correct one. (Alan J. Perlis, Epigrams in programming No. 7)
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Open Viewer with filled find topic

Post by Alex K. »

Hello,

Please try to use the following code:

Code: Select all

viewerControl.Report = report;
viewerControl.IsFindActivated = true;
viewerControl.FindValue = "find value";
Thank you.
User avatar
tpontow
Posts: 206
Joined: Thu Sep 06, 2012 8:46 am
Location: Bonn, Germany

Re: Open Viewer with filled find topic

Post by tpontow »

Hello Aleksey,

i'm doing the following now

Code: Select all

StiViewerControl viewer = new StiViewerControl
            {
                Report = report, 
                IsFindActivated = true, 
                FindValue = "find value"
            };

            report.Compile();
            viewer.Report.ShowWithWpfRibbonGUI();
but i does not work. The Find status bar is not shown all.

Do you have any other suggestions?

Thank you
Thorsten Pontow
Thorsten Pontow

It is easier to write an incorrect program than to understand a correct one. (Alan J. Perlis, Epigrams in programming No. 7)
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Open Viewer with filled find topic

Post by Alex K. »

Hello,

For WPF viewer is possible only show Find ToolBar:

Code: Select all

report.Render();
StiWpfViewerControl viewer = new StiWpfViewerControl();
viewer.Report = report;
viewer.InvokeToolFindEnable();
Grid.Children.Add(viewer);
Thank you.
User avatar
tpontow
Posts: 206
Joined: Thu Sep 06, 2012 8:46 am
Location: Bonn, Germany

Re: Open Viewer with filled find topic

Post by tpontow »

Hello Aleksey,

i found a solution at last. It cost me some time, nerve and effort. But now it works. When the report is opening i now have an already searched report in a WPFRibbonViewer with all found places highlighted. I needed to use some reflection but that's ok for me. :-)

Here's the code:

Code: Select all

report.Render();
            report.ShowWithWpfRibbonGUI();

            StiWpfRibbonViewerWindow viewerForm = StiGuiOptions.GetViewerFormWithRibbonGUI(report, StiGuiMode.Wpf) as StiWpfRibbonViewerWindow;
            if (!ReferenceEquals(viewerForm, null))
            {
                Type viewerFormType = viewerForm.GetType();
                FieldInfo viewerControlField = viewerFormType.GetField("viewerControl", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
                if (!ReferenceEquals(viewerControlField, null))
                {
                    StiWpfRibbonViewerControl viewerControl = (StiWpfRibbonViewerControl)viewerControlField.GetValue(viewerForm);
                    if (!ReferenceEquals(viewerControl, null))
                    {
                        Type viewerControlType = viewerControl.ViewerControl.GetType();
                        FieldInfo textboxFindField = viewerControlType.GetField("textBoxFind", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
                        if (!ReferenceEquals(textboxFindField, null))
                        {
                            TextBox textBoxFind = (TextBox)textboxFindField.GetValue(viewerControl.ViewerControl);
                            if (!ReferenceEquals(textBoxFind, null))
                            {
                                textBoxFind.Text = "Replace with your own SearchPhrase here";
                                viewerControl.ViewerControl.InvokeFind();
                            }

                        }

                    }

                }
            }
A little bit tricky but so what! The end justifies the means.

Regards
Thorsten Pontow
Thorsten Pontow

It is easier to write an incorrect program than to understand a correct one. (Alan J. Perlis, Epigrams in programming No. 7)
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Open Viewer with filled find topic

Post by HighAley »

Hello.

Thank you for posting this solution.
We are very glad to have such customers.

Thank you.
Post Reply