DevExpress report is really powerful, a variety of tricks, dazzling.
This time use Xtrareport Development Report, many questions in the official document does not have the detailed explanation, hereby records.
1. The Formattingrules attribute in Xtrareport is a condition (Condition) that can only return a bool value, not the expression I want.
2, according to Xtrareport official document to drag the control of the way to create the calculatedfiled is the expression I want.
1 The control is not flexible in the way it is, and the dataset type used by the DataSource (data source) of the Xtrareport object must specify the DataMember property when constructing Xtrareport.
This. CalculatedField1 =NewCalculatedfield {DataMember="Product", Expression="Iif ([id]==1,-2,2)", Name="CalculatedField1" }; This. Calculatedfields.addrange (Newdevexpress.xtrareports.ui.calculatedfield[] { This. CalculatedField1});//This field cannot be represented by placing the calculated field in the calculated field collection of the report. This. DataMember ="Product"; This. DataSource =ds; This. XRTABLECELL1.DATABINDINGS.ADD ("Text",NULL,"Product.calculatedfield1");
However, these are the drag-and-drop controls that are automatically generated and do not need to be written manually.
2 "in the form of pure code, my data source is the list<> type, it is important to note that at the time of construction, you must not specify the DataMember property.
This. CalculatedField1 =NewCalculatedfield {//DataMember = "Product",//you must not set the DataMember property by using list as the data sourceExpression ="Iif ([id]==1,-2,2)", Name="CalculatedField1" }; This. Calculatedfields.addrange (Newdevexpress.xtrareports.ui.calculatedfield[] { This. CalculatedField1}); //This . DataMember = "Product";//you must not set the DataMember property by using list as the data source This. DataSource =list; This. XRTABLECELL1.DATABINDINGS.ADD ("Text",NULL,"CalculatedField1");
3. The Xtrareport report does not appear to support the RDLC Row group (rowgroup) and column group (Columngroup), which I may not have found.
Implementing an expression in an RDLC report using Xtrareport's calculatedfiled (calculated field)