2
votes

I would like to hide the preview tab in the crystal report viewer in my WPF application. A link to the picture is shown below.
Update: I would like to remove the tabcontrol "button" on the upper left corner of the window.

I am using Crystal reports version 13. I have tried to find a solution to my problem, including here in stackoverflow, but all the solutions are for different technology.

enter image description here

1
If not preview, what do you want to see on screen then? - Arvo
I would like to see the preview page, but not the tabcontrol itself. I would like to get rid of that 0.5 * 2 cm section, hiding it, adn freeing up that line section of the screen. - Daniel
Ah, sorry, I misunderstood a bit :) - Arvo

1 Answers

0
votes

please try This

CrystalReportsViewer1.ViewerCore.ReportSource = CRobj;

        HidePreviewTabFromCRV();
    }

    private void HidePreviewTabFromCRV()
    {
        //visiual Tree
        var y = GetChild<System.Windows.Controls.Primitives.TabPanel>(CrystalReportsViewer1.ViewerCore);
        y.Visibility = Visibility.Collapsed;
    }

    private TargetType GetChild<TargetType>(DependencyObject o)
       where TargetType : DependencyObject
    {
        if (o == null || o is TargetType)
            return (TargetType)o;

        int i = 0;
        if (VisualTreeHelper.GetChildrenCount(o) == 2 && VisualTreeHelper.GetParent(o).GetType() == typeof(TabControl))
            i = 1; // We Arrive Our Destination

        return GetChild<TargetType>(VisualTreeHelper.GetChild(o,i));
    }