How to hide the Group Tree of a Crystal Report in WPF?

19,034

Solution 1

I finally found a solution that works, by manually finding the side panel and then hiding it:

var sidepanel = crystalReportsViewer1.FindName("btnToggleSidePanel") as ToggleButton;
if (sidepanel != null) {
    crystalReportsViewer1.ViewChange += (x, y) => sidepanel.IsChecked = false;
}

adding this namespace:

using System.Windows.Controls.Primitives;

The problem was that the WPF ReportViewer is slightly diferent to the Win Forms one, some properties (such as ToolPanelView and ShowGroupTreeButton) have been removed, I tried many different things but the above was the only that did the trick.

Solution 2

There also is a property on report viewer you can set as follows:

yourViewer.ToggleSidePanel = Constants.SidePanelKind.None;

I think this is a bit safer in case the Crystal Reports team decides to rename that button.

Solution 3

You can change it from the designer by changing the 'ToolPanelView' to 'None' and hide the button by changing 'ShowGroupTreeButton' to 'false'. Previous versions had a method to explicitly hide the group tree but I believe it's been deprecated in the version you are using. To change the properties in code behind:

crystalreportviewer.ToolPanelView = TooPanelViewType.None;
crystalreportviewer.ShowGroupTreeButton = false;

Solution 4

there is a property DisplayGroupTree . and you can avoid the free space by using this code

CrystalReportViewer1.DisplayGroupTree = false;

CrystalReportViewer1.HasToggleGroupTreeButton = false;

Solution 5

Use the command to hide the panel.

CrystalReportViewer1.ToolPanelView = CrystalDecisions.Windows.Forms.ToolPanelViewType.None

I ran into the same issue as Crystal Report changes the convention. In older version of the Crystal report would hide the button and not show the panel on the left hand side. CrystalReportViewer1.ShowGroupTreeButton = False

Share:
19,034
Mohammad Sepahvand
Author by

Mohammad Sepahvand

Updated on August 04, 2022

Comments

  • Mohammad Sepahvand
    Mohammad Sepahvand over 1 year

    I'm using VS2010 and Crystal reports 13.

    Is there any way to collapse/hide the group tree box that appears on the left hand side of my generated report? I saw a couple of proposed solutions but none seem to work for me.

    Thanks in advance.