如何合并dataGridView标题行 winForm

abiao1421 2008-01-15 06:07:10
效果如下:

|条码  |  名称   |    进货    |  销售      |   库存 |
|    |       |-----------------------------------|  |
|    |       | 数量 | 进格  | 数量 | 售格  |       |
|--------------------------------------------------------------------|
00001 | 商品1   | 2.00 | 20.00 | 10.00 | 22.00 | 10.00 |

这样的标题头怎么实现呀,请大哥帮忙.
...全文
644 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
peterb 2008-01-15
  • 打赏
  • 举报
回复
这个需要自己使用gdi+绘制
GhostAdai 2008-01-15
  • 打赏
  • 举报
回复
mark,要下班咯~
九章落地 2008-01-15
  • 打赏
  • 举报
回复
http://topic.csdn.net/u/20070210/16/19a6be86-7aa8-40d5-a3e9-05e8994ed61b.html
棋圣 2008-01-15
  • 打赏
  • 举报
回复
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
DataControlRowType elemType = e.Row.RowType;
if (e.Row.RowType == DataControlRowType.Header)
{
GridViewRow dgi = new GridViewRow(0, -1, DataControlRowType.Header, DataControlRowState.Normal);
GridViewRow dgi1 = new GridViewRow(0, -1, DataControlRowType.Header, DataControlRowState.Normal);
Table tb = new Table();
tb = (Table)GridView1.Controls[0];
tb.Rows.Clear();
tb.Rows.AddAt(0, dgi);
tb.Rows.AddAt(1, dgi1);
TableCell tc11 = new TableCell();
TableCell tc12 = new TableCell();
TableCell tc13 = new TableCell();
TableCell tc14 = new TableCell();
TableCell tc15 = new TableCell();
TableCell tc16 = new TableCell();
TableCell tc17 = new TableCell();
TableCell tc18 = new TableCell();
TableCell tc19 = new TableCell();

TableCell tc20 = new TableCell();
TableCell tc21 = new TableCell();
TableCell tc22 = new TableCell();
TableCell tc23 = new TableCell();
TableCell tc24 = new TableCell();
TableCell tc25 = new TableCell();
TableCell tc26 = new TableCell();
TableCell tc27 = new TableCell();
TableCell tc28 = new TableCell();
TableCell tc29 = new TableCell();
TableCell tc210 = new TableCell();
TableCell tc211= new TableCell();
TableCell tc212= new TableCell();
TableCell tc213= new TableCell();
TableCell tc214= new TableCell();

tc11.Text = "日期";
tc11.RowSpan = 2;
tc11.Height = 44;
tc11.Font.Bold = true;
tc11.HorizontalAlign = HorizontalAlign.Center; /*tc11.RowSpan = 2;*/
dgi.Cells.Add(tc11);
tc12.Text = "全宗";
tc12.Font.Bold = true;
tc12.HorizontalAlign = HorizontalAlign.Center;
tc12.RowSpan = 2;
dgi.Cells.Add(tc12);
tc13.Text = "合计档案";
tc13.Font.Bold = true;
tc13.HorizontalAlign = HorizontalAlign.Center;
tc13.RowSpan = 2;
dgi.Cells.Add(tc13);
tc14.Text = "案卷排架长度";
tc14.Font.Bold = true;
tc14.RowSpan = 2;
tc14.HorizontalAlign = HorizontalAlign.Center; /*tc11.RowSpan = 2;*/
dgi.Cells.Add(tc14);
tc15.Text = "现行档案";
tc15.Font.Bold = true;
tc15.ColumnSpan = 3;
tc15.HorizontalAlign = HorizontalAlign.Center;
dgi.Cells.Add(tc15);
tc16.Text = "历史档案";
tc16.Font.Bold = true;
tc16.ColumnSpan = 2;
tc16.HorizontalAlign = HorizontalAlign.Center;
dgi.Cells.Add(tc16);
tc17.Text = "声像档案";
tc17.Font.Bold = true;
tc17.ColumnSpan =4;
tc17.HorizontalAlign = HorizontalAlign.Center; /*tc11.RowSpan = 2;*/
dgi.Cells.Add(tc17);
tc18.Text = "专门档案";
tc18.Font.Bold = true;
tc18.ColumnSpan = 3;
tc18.HorizontalAlign = HorizontalAlign.Center;
dgi.Cells.Add(tc18);
tc19.Text = "资料";
tc19.Font.Bold = true;
tc19.ColumnSpan = 3;
tc19.HorizontalAlign = HorizontalAlign.Center;
dgi.Cells.Add(tc19);

tc20.Text = "合计";
tc20.Font.Bold = true;
tc20.HorizontalAlign = HorizontalAlign.Center;
dgi1.Cells.Add(tc20);
tc21.Text = "永久";
tc21.Font.Bold = true;
tc21.HorizontalAlign = HorizontalAlign.Center;
dgi1.Cells.Add(tc21);
tc22.Text = "长期";
tc22.Font.Bold = true;
tc22.HorizontalAlign = HorizontalAlign.Center;
dgi1.Cells.Add(tc22);
tc23.Text = "革命历史";
tc23.Font.Bold = true;
tc23.HorizontalAlign = HorizontalAlign.Center;
dgi1.Cells.Add(tc23);
tc24.Text = "民国";
tc24.Font.Bold = true;
tc24.HorizontalAlign = HorizontalAlign.Center;
dgi1.Cells.Add(tc24);
tc25.Text = "合计";
tc25.Font.Bold = true;
tc25.HorizontalAlign = HorizontalAlign.Center;
dgi1.Cells.Add(tc25);
tc26.Text = "录音录像影片";
tc26.Font.Bold = true;
tc26.HorizontalAlign = HorizontalAlign.Center;
dgi1.Cells.Add(tc26);
tc27.Text = "光盘";
tc27.Font.Bold = true;
tc27.HorizontalAlign = HorizontalAlign.Center;
dgi1.Cells.Add(tc27);
tc28.Text = "照片";
tc28.Font.Bold = true;
tc28.HorizontalAlign = HorizontalAlign.Center;
dgi1.Cells.Add(tc28);
tc29.Text = "合计";
tc29.Font.Bold = true;
tc29.HorizontalAlign = HorizontalAlign.Center;
dgi1.Cells.Add(tc29);
tc210.Text = "永久";
tc210.Font.Bold = true;
tc210.HorizontalAlign = HorizontalAlign.Center;
dgi1.Cells.Add(tc210);
tc211.Text = "长期";
tc211.Font.Bold = true;
tc211.HorizontalAlign = HorizontalAlign.Center;
dgi1.Cells.Add(tc211);
tc212.Text = "合计";
tc212.Font.Bold = true;
tc212.HorizontalAlign = HorizontalAlign.Center;
dgi1.Cells.Add(tc212);
tc213.Text = "现行";
tc213.Font.Bold = true;
tc213.HorizontalAlign = HorizontalAlign.Center;
dgi1.Cells.Add(tc213);
tc214.Text = "历史";
tc214.Font.Bold = true;
tc214.HorizontalAlign = HorizontalAlign.Center;
dgi1.Cells.Add(tc214);

int nColumn = e.Row.Cells.Count;
for (int i = 0; i < nColumn; i++)
{
e.Row.Cells.RemoveAt(0);
}
}

if (e.Row.RowType == DataControlRowType.Footer)
{......}
leehniu 2008-01-15
  • 打赏
  • 举报
回复
嵌套一个datagridview在datagridview中,我之前是用datagrid做的,datagridview不知道可以不
changjiangzhibin 2008-01-15
  • 打赏
  • 举报
回复
啥子意思呀

110,568

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧