FastReport 复选框示例

发布时间 2023-04-07 10:10:26作者: sunwugang
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing;
using System.Data;
using FastReport;
using FastReport.Data;
using FastReport.Dialog;
using FastReport.Barcode;
using FastReport.Table;
using FastReport.Utils;

namespace FastReport
{
  public class ReportScript
  {
    private void Data1_AfterData(object sender, EventArgs e)
    {
      String str ="001_true;002|false;003_true;004_true;";
      string[] temp = str.Split(';');
      
      if (temp.Length > 0) 
      {
        for (int i = 0; i < temp.Length; i++)
        {
          string[] obj = temp[i].Split('_');
          if(obj[0] =="001" &&  obj[1] == "true") 
          {
            CheckBox1.Checked=true;
          }
          if(obj[0] =="002" &&  obj[1] == "true")
          {
            CheckBox2.Checked=true;
          }
          if(obj[0] =="003" && obj[1] == "true")
          {
            CheckBox3.Checked=true;
          }
          if(obj[0] =="004" && obj[1] == "true")
          {
            CheckBox4.Checked=true;
          }
        }
      }
    }
  }
}

预览效果: