本帖最后由 KearneyKang 于 2018-12-20 16:53 编辑
您好,问题已经解决了,这主要是由于你使用FetchData事件来设置控件的值。它是用文档-ReportEvents编写的。请尝试处理Detail_Format事件,其中为子报表控制分配报告,如下实现主要代码:- private void LabItems_Format(object sender, System.EventArgs e)
- {
- LabItemsResults rptLabResults = new LabItemsResults(dt);
- subItemIndexResult.Report = rptLabResults;
- }
复制代码- <blockquote> private void LabItems_Format(object sender, System.EventArgs e)
复制代码 在报表设计里添加这段代码触发 LabItems_Format这个事件
- this.detail.Format += new System.EventHandler(this.LabItems_Format);
复制代码
部分代码:
public partial class LabItems : GrapeCity.ActiveReports.SectionReport
{
DataSet _dsResult;
DataTable _dtCheckItems = null;
private int iRow = 0;
DataTable dt = new DataTable();
public LabItems(DataSet dsResult)
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
_dsResult = dsResult;
_dtCheckItems = _dsResult.Tables["CheckItemsByLaboratory"];
}
private void LabItems_Format(object sender, System.EventArgs e)
{
LabItemsResults rptLabResults = new LabItemsResults(dt);
subItemIndexResult.Report = rptLabResults;
}
private void LabItems_FetchData(object sender, FetchEventArgs eArgs)
{
if (iRow >= _dtCheckItems.Rows.Count)
{
return;
}
else
{
eArgs.EOF = false;
}
CheckItemsDTO checkItems = CheckItemsBLL.GetModel(_dtCheckItems.Rows[iRow]);
#region 显示项目检查信息
CheckItemsName.Text = checkItems.CheckItemName;//项目名称
//如果检验者ID不为空则说明不是外送检验项目
tbOperatorUser.Text = checkItems.OperatorUserName;//检验者
tbAssessorUser.Text = checkItems.AssessorUserName;//审核者
tbCheckEndDate.Text = Convert.ToDateTime(checkItems.CheckEndDate).ToShortDateString().ToString().Replace("/", "-");//检查时间
#endregion 显示项目检查信息
#region 显示项目指标结果
dt = pubBLL.GetDataTableBy(ref _dsResult, "CheckItemIndexResult_" + checkItems.ID);
if (dt.Rows.Count <= 0)
{
throw new Exception("【" + checkItems.CheckItemName + "】的结果指标记录数量为0");
}
Tools.WriterLog("【" + checkItems.CheckItemName + "】以下" + dt.Rows.Count.ToString() + "条结果:");
//LabItemsResults rptLabResults = new LabItemsResults(dt);
//subItemIndexResult.Report = rptLabResults;
#endregion 显示项目指标结果
iRow++;
}
}
|