Skip to content

Commit 4f0d6fe

Browse files
committed
update
1 parent 6017fb0 commit 4f0d6fe

File tree

1 file changed

+3
-77
lines changed
  • reporting-for-desktop/articles/report-designer/report-designer-for-wpf/creating-reports

1 file changed

+3
-77
lines changed

reporting-for-desktop/articles/report-designer/report-designer-for-wpf/creating-reports/scripting.md

Lines changed: 3 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ legacyId: 116357
77
This document describes the basic principles of _scripting_, which can be performed by handling the events of a report, and its [bands](../report-elements/report-bands.md) and [controls](../report-elements/report-controls.md).
88

99
This documents consists of the following sections.
10-
* [Scripting Overview](#overview)
11-
* [Maintaining Scripts](#maintain)
12-
* [Example: Custom Summary](#example)
10+
- [Scripting](#scripting)
11+
- [Scripting Overview](#scripting-overview)
12+
- [Maintaining Scripts](#maintaining-scripts)
1313

1414
<a name="overview"/>
1515

@@ -40,77 +40,3 @@ After the event is specified, a code template is automatically generated in the
4040
To check for errors in the report's script, click the **Validate** button. The validation result is displayed in the errors panel at the bottom of the Script Editor. Double-click the error item in the panel's list to go to the corresponding line of code. If all scripts are valid, the errors panel is empty.
4141

4242
![WPFDesigner_ScriptErrorPanel](../../../../images/img123171.png)
43-
44-
<a name="example"/>
45-
46-
## <a name="example"/>Example: Custom Summary
47-
This example demonstrates how to display the total number of product unit packs in a group.
48-
49-
To perform this, execute steps similar to the ones described in [Calculating Summaries](shaping-data/calculating-summaries.md), except that for the summary field, you should set the **Function** property to **Custom**.
50-
51-
![EUD_WpfReportDesigner_Scripting_1](../../../../images/img123899.png)
52-
53-
Then, the additional events are added to the label's **Scripts** property.
54-
55-
![EUD_WpfReportDesigner_Scripting_2](../../../../images/img123900.png)
56-
57-
You can handle these events in the following way.
58-
59-
**C#**
60-
61-
```csharp
62-
63-
// Declare a summary and a pack.
64-
double totalUnits = 0;
65-
double pack = 15;
66-
67-
private void label1_SummaryReset(object sender, System.EventArgs e) {
68-
// Reset the result each time a group is printed.
69-
totalUnits = 0;
70-
}
71-
72-
private void label1_SummaryRowChanged(object sender, System.EventArgs e) {
73-
// Calculate a summary.
74-
totalUnits += Convert.ToDouble(GetCurrentColumnValue("UnitsOnOrder"));
75-
}
76-
77-
private void label1_SummaryGetResult(object sender,
78-
DevExpress.XtraReports.UI.SummaryGetResultEventArgs e) {
79-
// Round the result, so that a pack will be taken into account
80-
// even if it contains only one unit.
81-
e.Result = Math.Ceiling(totalUnits / pack);
82-
e.Handled = true;
83-
}
84-
85-
```
86-
**VB.NET**
87-
88-
```vb
89-
90-
' Declare a summary and a pack.
91-
Private totalUnits As Double = 0
92-
Private pack As Double = 15
93-
94-
Private Sub label1_SummaryReset(ByVal sender As Object, ByVal e As System.EventArgs)
95-
' Reset the result each time a group is printed.
96-
totalUnits = 0
97-
End Sub
98-
99-
Private Sub label1_SummaryRowChanged(ByVal sender As Object, ByVal e As System.EventArgs)
100-
' Calculate a summary.
101-
totalUnits += Convert.ToDouble(GetCurrentColumnValue("UnitsOnOrder"))
102-
End Sub
103-
104-
Private Sub label1_SummaryGetResult(ByVal sender As Object, _
105-
ByVal e As DevExpress.XtraReports.UI.SummaryGetResultEventArgs)
106-
' Round the result, so that a pack will be taken into account
107-
' even if it contains only one unit.
108-
e.Result = Math.Ceiling(totalUnits / pack)
109-
e.Handled = True
110-
End Sub
111-
112-
```
113-
114-
Finally, switch to the [Print Preview](../document-preview.md) tab and view the result.
115-
116-
![EUD_WpfReportDesigner_Scripting_3](../../../../images/img123901.png)

0 commit comments

Comments
 (0)