Page 1 of 1

Open Viewer with filled find topic

Posted: Fri Oct 18, 2013 1:21 pm
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

Re: Open Viewer with filled find topic

Posted: Mon Oct 21, 2013 9:56 am
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.

Re: Open Viewer with filled find topic

Posted: Mon Oct 21, 2013 11:16 am
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

Re: Open Viewer with filled find topic

Posted: Mon Oct 21, 2013 12:51 pm
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.

Re: Open Viewer with filled find topic

Posted: Wed Oct 30, 2013 1:50 pm
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

Re: Open Viewer with filled find topic

Posted: Thu Oct 31, 2013 6:48 am
by HighAley
Hello.

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

Thank you.