ActiveReports动态添加列

//在报表内签了列是固定的,查询的数据字段不定,以前两列为坐标添加后面的列,

 

private void ReportPage_ReportStart(object sender, System.EventArgs e)
  {
 
   //病原菌抗生素实验数据
   DataTable byjdt=lansoft.getByjSy("9999");
   DataTable dt=lansoft.getDateTest();

   #region //添加,抗生素,pageHeader列
   if(dt!=null)
   {
    float left=bh.Left+bh.Width;
    float height=bh.Height;
    float leftdata=bhdata.Left+bhdata.Width;
    float heightdata=bhdata.Height;
    for(int i=0;i<dt.Rows.Count;i++)
    {
     //标题列//=======================================================
     TextBox txt = new DataDynamics.ActiveReports.TextBox();
     txt.Name = "";
     //txt.DataField = "";
     txt.Text=dt.Rows[i][0].ToString();
     txt.Alignment = DataDynamics.ActiveReports.TextAlignment.Left;
     txt.Border.BottomStyle = DataDynamics.ActiveReports.BorderLineStyle.Solid;
     txt.Border.LeftStyle = DataDynamics.ActiveReports.BorderLineStyle.Solid;
     txt.Border.TopStyle = DataDynamics.ActiveReports.BorderLineStyle.Solid;
     //边框
     if(i<dt.Rows.Count-1)     
      txt.Border.RightStyle = DataDynamics.ActiveReports.BorderLineStyle.None;      
     else
      txt.Border.RightStyle = DataDynamics.ActiveReports.BorderLineStyle.Solid;      
     txt.CanGrow = false;
     txt.MultiLine=true;
     txt.WordWrap=true;
     txt.DistinctField = null;
     //宽度0.5     
     txt.Left = left;
     left+=0.35f;
     txt.Style = "font-size: 10pt;text-align: left;font-family:宋体;";
     txt.VerticalAlignment = DataDynamics.ActiveReports.VerticalTextAlignment.Middle;
     txt.Width = 0.35f;
     txt.Top=bh.Top;
     txt.Height=height;
     //将TextBox添加到报表体中
     this.pageHeader.Controls.Add(txt);

     //数据列//=======================================================
     TextBox txtdata = new DataDynamics.ActiveReports.TextBox();
     txtdata.Name = "";
     txtdata.DataField = dt.Rows[i][0].ToString();
     //txtdata.Text=dt.Rows[i][0].ToString();
     txtdata.Alignment = DataDynamics.ActiveReports.TextAlignment.Center;
     txtdata.Border.BottomStyle = DataDynamics.ActiveReports.BorderLineStyle.Solid;
     txtdata.Border.LeftStyle = DataDynamics.ActiveReports.BorderLineStyle.Solid;
     txtdata.Border.TopStyle = DataDynamics.ActiveReports.BorderLineStyle.None;
     //边框
     if(i<dt.Rows.Count-1)     
      txtdata.Border.RightStyle = DataDynamics.ActiveReports.BorderLineStyle.None;      
     else
      txtdata.Border.RightStyle = DataDynamics.ActiveReports.BorderLineStyle.Solid;      
     txtdata.CanGrow = false;
     txtdata.MultiLine=true;
     txtdata.WordWrap=true;
     txtdata.DistinctField = null;
     //宽度0.5     
     txtdata.Left = leftdata;
     leftdata+=0.35f;
     txtdata.Style = "font-size: 10pt;text-align: left;font-family:宋体;";
     
     txtdata.VerticalAlignment = DataDynamics.ActiveReports.VerticalTextAlignment.Middle;
     txtdata.Width = 0.35f;
     txtdata.Top=bhdata.Top;
     txtdata.Height=heightdata;
     //将TextBox添加到报表体中
     this.detail.Controls.Add(txtdata);
     
    }
    this.DataSource=byjdt;
   }
   #endregion 

  }

 

转载于:https://www.cnblogs.com/WarCraftIII/archive/2010/03/26/1696573.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值