网站大量收购独家精品文档,联系QQ:2885784924

gridview表头合并程序.doc

  1. 1、本文档共8页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
网上找了个找,最终还是自己做的比较靠谱,道理很简单,直接看代码 代码: 1 /// summary 2 /// =================== 两行标题行 ======================== 3 /// /summary 4 /// param name=sender/param 5 /// param name=e/param 6 protected void GV1_RowCreated(object sender, GridViewRowEventArgs e) 7 { 8 if (e.Row.RowType == DataControlRowType.Header) 9 { 10 e.Row.Cells.Clear(); 11 string[] capText = { ID, 材料名称, 规格型号, 计量单位, 入库数量, 点验, 发料, 库存, 合同 }; 12 int[] capWidth = { 50, 0, 0, 0, 70, 150, 150, 150, 150 }; 13 int[] capRowSpan = { 2, 2, 2, 2, 2, 1, 1, 1, 1 }; 14 int[] capColSpan = { 1, 1, 1, 1, 1, 2, 2, 2, 2 }; 15 GV1.Controls[0].Controls.Add(CreateHeaderRow(capText, capWidth, capRowSpan, capColSpan)); 16 17 capText = new string[] { 数量, 金额, 数量, 金额, 数量, 金额, 单价, 金额 }; 18 capWidth = new int[] { 70, 80, 70, 80, 70, 80, 70, 80 }; 19 GV1.Controls[0].Controls.Add(CreateHeaderRow(capText, capWidth, capRowSpan, capColSpan, true)); 20 } 21 } 22 /// summary 23 /// ===================== 自定义标题行的方法 ========================= 24 /// /summary 25 /// param name=tcText单元格Text/param 26 /// param name=tcWidth单元格宽度,为0则不设置宽度/param 27 /// param name=tcRowSpanRowSpan/param 28 /// param name=tcColSpanColumnSpan/param 29 /// param name=noSpanRow若为True,则忽略行、列的合并Span/param 30 /// returns一行标题行/returns 31 private GridViewRow CreateHeaderRow(string[] tcText, int[] tcWidth, int[] tcRowSpan, int[] tcColSpan, bool noSpanRow = false) 32 { 33 GridViewRow rowHeader = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal); 34 TableHeaderCell thc; 35 for (int i = 0; i tcText.Length; i++) 36 { 37 thc = new TableHeaderCell(); 38 thc.Text = tcText[i]; 39 if (tcWidth[i] 0) { thc.Width = tcWidth[i]; }//若为0,则不设置width 40 if (!noSpanRow) 41

您可能关注的文档

文档评论(0)

1112111 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档