Hide Duplicate Values

With ActiveReports, you can hide duplicate values of a record. How you do this depends on the type of report you are using. Let's take a look at how to do it with each type of report.

Section Reports

In Section Reports, there are two ways to handle this. You can code in section events, or set a property in the designer or in code.

Using section events

In code, you can use the BeforePrint event to track the values and set a condition under which to render them. Then use the PageEnd event to clear the variable when each page finishes rendering. This ensures that the first record on each page always renders.


Dim strBuff As String  

Private Sub Detail_BeforePrint(...) Handles Detail.BeforePrint  
If (Me.TextBox1.Text <> strBuff) Then  
Me.TextBox1.Visible = True  
' Hide duplicate data  
Me.TextBox1.Visible = False  
End If  

strBuff = Me.TextBox1.Text  
End Sub  

Private Sub ActiveReport1_PageEnd(...) Handles MyBase.PageEnd  
' Resets the string so that the record renders on each new page  
strBuff = ""  
End Sub

// C#  

string strBuff;  

private void Detail_BeforePrint(object sender, System.EventArgs eArgs)  
if (this.TextBox1.Text != strBuff)  
this.TextBox1.Visible = true;  
// Hide duplicate data  
this.TextBox1.Visible = false;  

strBuff = this.TextBox1.Text;  

private void rptSimpleGroup_PageEnd(object sender, System.EventArgs eArgs)  
// Reset the string so the record prints on each new page  
strBuff = "";  

For more information, see Section Report Events in the User Guide.

Using the UnderlayNext property

The UnderlayNext property of the GroupHeader section, when set to True, superimposes the next section on top of the GroupHeader. To use this property to hide duplicate values, you need to do several things:

  1. Set your data query to order by the field that has duplicate values.
  2. Set the GroupHeader's DataField property to the field that has duplicate values.
  3. Move the textbox that is bound to the duplicated field into the GroupHeader section where it will not underlay a field in the following section.

You can see this in action on the Country field in the following sample that installs with ActiveReports: Documents\GrapeCity Samples\ActiveReports 10\Reports Gallery\C# (or VB.NET)\Reports\Section Report\UnderlayNext.rpx The sample report uses this SQL query:

SELECT * FROM Customers ORDER BY Country

and its GroupHeader1 section has the DataField property set to Country. Here's how the sample looks at design time (with background colors set on each section so that you can see what is happening): UnderlayNextDesignTime And here's how it looks at run time: Sample_UnderlayNext For more information about the sample, see the Report Gallery topic in the User Guide. The UnderlayNext report is near the bottom of the page.

Page and RDL Reports

In Page and RDL reports, there's a new feature in ActiveReports 10 that does the trick. The Tablix data region, kind of a combination of a table and a matrix, automatically hides duplicate data grouping row values by merging cells. Merged cells in a Tablix data region at run time. Merged cells in a Tablix data region at run time. For more information about Tablix and how it merges cells, see the following topics in our User Guide. Tablix | Cell Merging in Tablix


GrapeCity Developer Tools
comments powered by Disqus