This event is used by the reporting engine (see interface IWPReport) to create and navigate in data sets.
Also required is even OnFieldGetText to read field values.
Declaration C#
OnReportState(object Sender, string Name, int State, WPDynamic.IWPReportBand Band, ref bool Abort)
Declaration OCX
OnReportState(ByVal Name As String, ByVal State As Long, _
ByVal Band As WPTDynInt.IWPReportBand, Abort As Boolean)
This event occurs during report creation. It gives you a chance to prepare a database query, to advance to the next record and to prepare the attributes of the bands.
Parameters
Name:
This is the name of the band.
State:
This parameter is used to check the current processing state of the reporting engine:
0 (REP_BeforeProcessGroup): A reporting group is about to be started/looped. You need to set "Abort" to false, otherwise the group will not be processed. Usually you will need to prepare a sub query and set "Abort" to true in case the query is empty.
The event will also occur when the group is processed again - Count is >0 in this case.
1 (REP_PrepareText): A text band is prepared. It will be used next. Usually you have nothing to do - but you can modify the properties of the band paragraphs.
After the band was prepared, all paragraphs will be copied to editor #2 in the TextDynamic control and after that the event OnFieldGetText will be fired for all merge fields in the text.
2 : not used
3 (REP_PrepareHeader): A header band is prepared.
4 : not used
5 (REP_AfterProcessGroupData): The group data has been processed completely. You can use this state to sum up totals.
6 (REP_PrepareFooter): A footer band is prepared.
7: not used
8 (REP_AfterProcessGroup): The group was processed. You can use this event to move to next record.
Example:
This simplified C# example code loops all groups in the report template 10 times.
It has been created to be used as template in Your Application.
// This event is used to start, prepare and close a report group
// Usually you would use the "Name" to select a certain database,
// rewind it depending on State and set "Abort" to true
// when the last record was reached when State=0.
private void wpdllInt2_OnReportState(
object Sender,
string Name, int State,
IWPReportBand Band,
ref bool Abort)
{
switch(State)
{
case 0: //REP_BeforeProcessGroup
{
// If Band.Count=1 take "Name" to open a data base query and
// move to first Record.
// Set Abort to TRUE if the query has the state "EOF" (EndOfFile)
// Here also Set total variables to 0.
Abort = Band.Count>10;
break;
}
case 1: //REP_PrepareText
{
// We can process a text band depending on a condition
break;
}
case 3: //REP_PrepareHeader
{
// We can process a header band depending on a condition
break;
}
case 5: //REP_AfterProcessGroupData
{
// Take the named data set and post process the current row.
// This event will only be triggerd if the group contained
// a data row. You can use it to calculate totals.
// (Band.Count will be -1 in this event)
break;
}
case 6: //REP_PrepareFooter
{
// We can process a footer band depending on a condition
break;
}
case 8: //REP_AfterProcessGroup
{
// This event takes place after the group data and footer
// have been processed. After this event any headers are
// created. (Band.Count will be -1 in this event)
break;
}
}
}
Note:
If you are using the Active-X and your developing system does not provide access to the interface passed as parameter, use the property EventReportBand instead.
Category