Http://www.cnblogs.com/babyt/archive/2008/01/03/1024941.html In the Crystal report in the implementation of arbitrary select the specified field display in a friend message said there is no C # version, recently have time to rewrite a bit. One is the use of the VS2005 c#2.0 + Crystal 2008, in addition to the template to implement the way also changed.
Here is a step-by-step, the implementation of the template and XSD files and MDB files, from the Crystal Report in the implementation of arbitrary selection of the specified field to display the article download But the template is here to illustrate that the header section of the template in this article does not use parameter fields, but instead uses a formula field. As shown in the following figure
The final effect is
Each control uses a default name, and the main event is click
CR2008 automatically add the following code 1 using Crystaldecisions.shared; 2 using CrystalDecisions.CrystalReports.Engine; 3 using CrystalDecisions.Windows.Forms; Click event code: 1 private void Button1_Click (object sender, EventArgs e) 2 { 3 4 5 String cnstr = ""; 6//Keep the field string 7 String fldstr = ""; 8//Keep an array of field names 9 string[] Fldarr=new string[6]; Ten int i = 0; int j = 0; 12 13 14 /--------------------------------------------------------------------- 16//Get the selected field and process it if (checkbox1.checked = = True) Fldstr = Fldstr + "," + checkbox1.text; if (checkbox2.checked = = True) Fldstr = Fldstr + "," + checkbox2.text; An if (checkbox3.checked = = True) Fldstr = Fldstr + "," + checkbox3.text; if (checkbox4.checked = = True) Fldstr = Fldstr + "," + checkbox4.text; if (checkbox5.checked = = True) Fldstr = Fldstr + "," + checkbox5.text; /if (checkbox6.checked = = True) Fldstr = Fldstr + "," + checkbox6.text; 29 if (Fldstr = "") { MessageBox.Show ("Please select the fields to display"); return; 33} 34 The IF (FLDSTR). Substring (0, 1) = = ",") Fldstr = Fldstr. Substring (1, Fldstr. LENGTH-1); 37 38 |