//初始化报表的各个项目
private void GridReportInit()
{
Report.Initialize += new _IGridppReportEvents_InitializeEventHandler(Report_Initialize); //初始化报表来源,即报表存储的位置
Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(Report_FetchRecord);//画报表的函数调用,主要是画出报表的格式 这个事件主要是在存在明细网格时才会起作用
}
//导入报表的存储路径
void Report_Initialize()
{
string FilePath = Application.StartupPath+@"\Resources\ReportTemplate\入院评估单.grf";
Report.LoadFromFile(FilePath);//导入报表的存储路径
Report_FetchRecord();
}
//画报表的函数调用,主要是画出报表的格式
void Report_FetchRecord()
{
//定义报表的存储表
DataTable m_dtReport = new DataTable();
//取出报表需要的数据从查询的数据中Dsreportdetalrec
m_dtReport = Dsreportdetalrec.Tables[0];
if (m_dtReport.Rows.Count > 0)//表中存在数据
{
IGRControl control = Report.FindFirstControl();//定义IGRControl类型控件并且取出报表中的第一个控件值
while (control != null)//循环给每个控件赋值
{
if (control is IGRStaticBox) //判断控件是否是静态框
{
if (control.Name != null)//取出静态框中的tag的值即是属性标识的值
{
if (control.Name == "评估者")
{
DataRow[] drRows1 = m_dtReport.Select(string.Format("item_name='{0}'", control.Name));
if (drRows1.Length > 0)
{
if (control.AsStaticBox.Text == null)
{
string[] str = drRows1[0]["item_value"].ToString().Split('/');
if (str.Length > 0 && !string.IsNullOrWhiteSpace(str[0].ToString()))
{
control.AsStaticBox.Text = str[0].ToString();//给控件赋值
}
else
{
control.AsStaticBox.Text = "";
}
}
}
}
else if (control.Name == "过敏源")
{
DataRow[] drRows = m_dtReport.Select(string.Format("item_name='{0}'", control.Name));
if (drRows.Length > 0)
{
if (control.AsStaticBox.Text == null)
{
if (drRows[0]["item_value"].ToString() == "" || drRows[0]["item_value"].ToString() == "无" || string.IsNullOrEmpty(drRows[0]["item_value"].ToString()))
{
control.AsStaticBox.ForeColor =(uint)System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black);
Grd++和C# winform的对接
最新推荐文章于 2022-11-02 11:47:01 发布