Programming Change Formula Field Sample Code

zhaozj2021-02-16  52

Using crystaldecisions.crystalreports.Engine;

Namespace GMEDicine {///

/// FormGMedicine's summary description. /// public class FormGMedicine: System.Windows.Forms.Form {private const string CR_PATH = @ "../../ RPTGMedicine.rpt"; private const string FORMULA_FIELD_NAME = @ "Group"; private string [ ] Formula_field_text = {"{Customer. Country and Region}", "{Customer. City}", "{Customer. Contact Position}", "{Customer. Region"};

private CrystalDecisions.Windows.Forms.CrystalReportViewer crvGMedicine; private GMedicine.RPTGMedicine rptGMedicine; private System.Windows.Forms.ComboBox cbxSelectGroup; private void FormGMedicine_Load (object sender, System.EventArgs e) {LoadFormulaList ();

CRVGMedicine.reportsource = rPTGMedicine;

CRVGMedicine.refreshreport ();

Private void cbxselectgroup_selectedindIndexchanged (Object Sender, System.EventArgs E) {FormulafieldDefinition Formulafield;

Formulafield = getformulafield (rPTGMedicine, formula_field_name);

Formulafield.text = cbxselectgroup.selectedItem.toString ();

CrvgMedicine.refreshreport ();} Private formulafieldDefinition getformulafield (ReportDocument Report, String formulafieldname) {FormulafieldDefinition formulafield;

/ / Get formulafielddefinition, // and return this object by name. formulaField = Report.DataDefinition.FormulaFields [formulaFieldName]; if (! formulaField = null) return formulaField; else return null;} private void LoadFormulaList () {foreach (string formula in FORMULA_FIELD_TEXT) {cbxSelectGroup.Items.Add (formula);} }}}

转载请注明原文地址:https://www.9cbs.com/read-22473.html

New Post(0)