Never access the Fields collection outside of the FetchData or DataInitialize events.
For example, the following code will cause problems in the Detail section Format event:
C#
this.TextBox1.Text = this.Fields["ProductName"].Value.ToString();
VB.NET
Me.TextBox1.Text = this.Fields["ProductName"].Value.ToString()
Why this will cause problems:
In ActiveReports there are a few event sequences that you can count on, such as a particular section's Format event firing before the BeforePrint event, and the BeforePrint event firing before the AfterPrint event. However, some sections will change the order in which events fire depending on the report layout, property settings, etc. The FetchData event may fire several times before the Detail Format event does. Every time the FetchData event fires, a row of data is processed. ActiveReports knows how to handle this and the report will generate correctly. However, if you are referencing the Fields collection from another section, such as the Detail Format event, it is not guaranteed to be pointing at the same record as the one being processed. In other words, you may be grabbing a value from the wrong record. There is never a need to access the Fields collection outside of the FetchData or DataInitialize event.
Never access controls or sections (after the ReportStart event) from an event that is not one of the three events for the section which contains the control.
For example, the following code will cause problems in the Detail section Format event:
C#
this.Sections["GroupHeader1"].Controls["lblIsValid"].Text = True;
VB.NET
Me.Sections["GroupHeader1"].Controls["lblIsValid"].Text = True
Why this will cause problems:
ActiveReports is not processing the GroupHeader section when the Detail Format event fires. In fact, it may have already been rendered. This can cause strange behavior in your report output and should never be done.