Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 300
Mohammad Sepahvand Avatar asked Oct 25 '11 14:10

Mohammad Sepahvand


People also ask

How do I hide in Crystal Reports?

To show or hide Crystal Reports From the Application Settings list, choose Foundation > Advanced Options > Show/Hide Crystal Reports, and then click Open.

What is crystal report in WPF?

Basically, Crystal Reports has been the reporting tool of choice included with Visual Studio. While the Crystal Report engine is not included with VS 2010, there is still a Crystal Report template included that stubs our project as a Crystal Reports project.

What is crystal report in VB?

Crystal Report is a Reporting application that can generate reports from various Data Sources . We can Create Reports , Print and Print Preview of reports from Crystal Reports . Crystal Reports are compatible with most popular development environments like VB.NET etc. and SQL Server also .


5 Answers

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.

like image 174
Mehdi Khalili Avatar answered Nov 06 '22 11:11

Mehdi Khalili


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.

like image 35
Mohammad Sepahvand Avatar answered Nov 06 '22 11:11

Mohammad Sepahvand


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;
like image 30
Justin Avatar answered Nov 06 '22 11:11

Justin


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

CrystalReportViewer1.DisplayGroupTree = false;

CrystalReportViewer1.HasToggleGroupTreeButton = false;

like image 31
Jidheesh Rajan Avatar answered Nov 06 '22 11:11

Jidheesh Rajan


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

like image 29
g5thomas Avatar answered Nov 06 '22 11:11

g5thomas