Dynamically add the code of the field you need in the crystal report
// First instantiate a report (zkck) cr1 report.zkck cr1 = new gjmis.wzsys.reports.zkck (); conn = new sqlConnection (this.strcon); sqldap = new sqldataadapter (); Selcmd = new SQLCOMMAND () Sqldap.selectcommand = SELCMD; SELCMD.COMMANDTEXT = "[zkckbd]"; // Call stored procedure SELCMD.COMMANDTYPE = CommandType.StoredProcedure; SELCMD.CONNECTION = conn; // Receive Parameters passing through the web page (ie, in the report The field to be displayed) String [] Field = regex.unescape ((Request ["StrCheck"])). Split (','); Selcmd.Parameters.Add ("@ iMonth", convert.Toint32 (Request [" IMONTH "])); Sqldap.Fill (SqlDST," ZKCK "); // Instantiate the text object in the report textObject [] txt = new textObject [17]; textObject [] txt_1 = new textObject [17]; textObject [ ] txt_2 = new TextObject [17]; // custom formula instantiated report FormulaFieldDefinition [] field_1 = new FormulaFieldDefinition [17]; FormulaFieldDefinition [] field_2 = new FormulaFieldDefinition [17]; // custom report instantiated Formula (summary in detail) FormulafieldDefinition [] Tot_1 = new formulafielddefinition [18]; formulafielddefinition [] Tot_2 = new formulafielddefinition [18]; for INT i = 1; i <= 17; i ) {// For instantiated report text corresponds to TXT [I-1] = (TextObject) cr1.reportdefinition.reportObjects ["txt" Converts ["TXT" Convert .Tostring (i)]; txt_1 [i-1] = (textObject) cr1.reportdefinition.reportObjects ["txt_1" convert.toString (i)]; txt_2 [i-1] = (textObject) cr1.reportDefinition.reportObjects ["TXT_2" Convert.TOString (i)]; // For the instantiated custom formula, Field_1 [i-1] = cr1.dataDefinition.formulafields ["Field_1" Converts for the custom formula in the report. TSTRING (I)]; Field_2 [I-1] = cr1.dataDefinition.formulafields ["Field_2" Convert.TOString (i)]; TOT_1 [I-1] =
CR1.DATADEFINITION.FORMULAFIELDS ["TOT_1" Convert.TOString (i)]; TOT_2 [I-1] = cr1.dataDefinition.formulafields [TOT_2 " Convert.TOString (i)]; // Initial Settings All Reports All objects do not show cr1.reportdefinition.reportObjects ["tot1" convert.toString (i) "1"]. Objectformat .Enablesuppress = true; cr1.reportdefinition.reportObjects ["TOT2" Convert.Tostring (i) "1"] ObjectFormat .EnableSuppress = true;.. cr1.ReportDefinition.ReportObjects [ "field1" Convert.ToString (i) "1"] ObjectFormat .EnableSuppress = true; cr1.ReportDefinition.ReportObjects [ "field2" Convert.ToString (i) "1"] ObjectFormat .EnableSuppress = true;.. cr1.ReportDefinition.ReportObjects [ "ln1" Convert.ToString (i)] ObjectFormat .EnableSuppress = true; cr1.ReportDefinition.ReportObjects [ "ln2 " Convert.TOSTRING (I)]. Objectformat .Enablesuppress = true;} for (int i = 0; i Cr1.reportDefinition.reportObjects ["Field2" Convert.TOSTRING (i 1) "1"]. Objectformat.Enablesuppress = false; cr1.reportdefinition.reportObjects ["tot1" convert.toString (i 1) " 1 "] ObjectFormat .EnableSuppress = false;. cr1.ReportDefinition.ReportObjects [" tot2 " Convert.ToString (i 1) " 1 "] ObjectFormat .EnableSuppress = false;. cr1.ReportDefinition.ReportObjects [" ln1 " . Convert.ToString (i 1)] ObjectFormat.EnableSuppress = false; cr1.ReportDefinition.ReportObjects [ "ln2" Convert.ToString (i 1)] ObjectFormat.EnableSuppress = false;.} tot_1 [17] = cr1. DATADEFINITION.MMULAFIELDS ["TOT_118"]; TOT_2 [17] = cr1.dataDefinition.formulafields ["TOT_218"]; // Tot_1 [17] .text = "SUM ({zkckbd.})"; TOT_2 [17] .Text = "SUM ({zkckbd. Total})"; // Positioning some of the location that always displayed // cr1.reportdefinition.reportObjects ["tot1181"]. Left = cr1.reportdefinition.reportObjects ["Tot1181" ] .Objectformat.enablesuppress = false; // cr1.reportdefinition.reportObjects ["tot1181"]. Left = cr1.reportdefinition.reportObjects ["TOT218 1 ".] ObjectFormat.EnableSuppress = false; cr1.ReportDefinition.ReportObjects [" tot1181 ".] Left = cr1.ReportDefinition.ReportObjects [" tot1181 "] Left- (18-field.Length) * 1590;. Cr1.ReportDefinition. . ReportObjects [ "tot2181"] Left = cr1.ReportDefinition.ReportObjects [ "tot2181"] Left- (18-field.Length) * 1590;.. cr1.ReportDefinition.ReportObjects [ "fieldzs1"] Left = cr1.ReportDefinition.ReportObjects ["Fieldzs1"]. LEFT- (18-Field.length) * 1590; cr1.ReportDefinition.ReportObjects [ "fieldje1"] Left = cr1.ReportDefinition.ReportObjects [ "fieldje1"] Left- (18-field.Length) * 1590;... cr1.ReportDefinition.ReportObjects [ "txt_hj"] Left = cr1 .ReportDefinition.ReportObjects [ "txt_hj"] Left- (18-field.Length) * 1590;... cr1.ReportDefinition.ReportObjects [ "txt_je"] Left = cr1.ReportDefinition.ReportObjects [ "txt_je"] Left- (18 -field.Length) * 1590;. cr1.ReportDefinition.ReportObjects [ "txt_zs"] Left = cr1.ReportDefinition.ReportObjects [ "txt_zs"] Left- (18-field.Length) * 1590;. cr1.ReportDefinition.ReportObjects [ . "txtzbr"] Left = cr1.ReportDefinition.ReportObjects [ "txt_zs"] Left;.. cr1.ReportDefinition.ReportObjects [ "txt_title"] Width = 1845 cr1.ReportDefinition.ReportObjects [ "txt1"] Width * (field. .Length); // The movement of the text and fields (below is the necessary adjustment to some lines) lbltmp.text = "