In a section layout, you can use conditions in the Format event to control the display of report's detail section at run time.
These steps assume that you have already added a Section Report (code-based) template in a Visual Studio project and connected it to a data source. See Adding an ActiveReport to a Project and Bind Reports to a Data Source for further information.
Field Name | Properties |
---|---|
ProductName | Location: 0, 0.104 in Size: 2.667, 0.2 in |
Discontinued | Location: 2.667, 0.104 in Size: 2.021, 0.2 in |
ReorderLevel | Location: 4.688, 0.104 in Size: 1.812, 0.2 in |
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Detail_Format event. |
Copy Code
|
---|---|
If Me.txtReorderLevel1.Value = 0 And Me.txtDiscontinued1.Value = False Then Me.Detail1.Visible = True Me.txtReorderLevel1.Text = "Need to Reorder" Me.txtReorderLevel1.ForeColor = System.Drawing.Color.DarkRed Else Me.Detail1.Visible = False End If |
To write the code in C#
C# code. Paste INSIDE the detail_Format event. |
Copy Code
|
---|---|
if (int.Parse(txtReorderLevel1.Value.ToString()) == 0 && txtDiscontinued1.Text == "False") { this.detail1.Visible = true; this.txtReorderLevel1.Text = "Need to Reorder"; this.txtReorderLevel1.ForeColor = System.Drawing.Color.DarkRed; } else { this.detail1.Visible = false; } |