In ActiveReports, C# expressions can be used in the DataField property to specify textbox output in a report, such as date/time, mathematical calculations or conditional values. All field expressions used in the DataField property begin with the equals sign (=).
Change the DataField property for the text box to the mathematical calculation desired.
Examples: =UnitPrice+5
=Quantity-5
=Quantity*UnitPrice
=UnitPrice/QuantityPerUnit
Change the DataField property for the text box to the substring needed. If setting up grouping, change the GroupHeader's DataField property to the same substring.
Example: =ProductName.Substring(0, 1)
Change the DataField property for the text box to the following.
Example: =System.DateTime.Now.ToString()
Change the DataField property for the text box to the conditional statement desired.
Example: =(UnitsInStock > 0)?"In Stock":"Backorder"
Change the DataField property for the text box to the following.
Examples: ="There are " + UnitsInStock + " units of " + ProductName + " in stock."
=TitleOfCourtesy + " " + FirstName + " " + LastName
Note: ActiveReports automatically handles null values, replacing them with an empty string. |
Change the DataField Property for the text box to the following.
Example: =(double)System.Math.Round(UnitPrice*UnitsOnOrder,2)
Change the DataField Property for the text box to the following to get the remainder (2 in this case).
Example: =22%(5)
Change the DataField Property for the text box to the following to replace nulls with your own value.
=(Region == System.DBNull.Value) ? "No region specified" : Region