玄铁剑

成功的途径:抄,创造,研究,发明...
posts - 128, comments - 42, trackbacks - 0, articles - 174

导航

<2010年10月>
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

常用链接

留言簿(5)

随笔分类

随笔档案

文章分类

收藏夹

AJAX

asp.net網絡鏈接

Delphi Link

IronPython

Microsoft

Other Blogs

OtherSite

SliverLight

Test

免费asp.net控件

其它链接

搜索

  •  

积分与排名

  • 积分 - 217462
  • 排名 - 26

最新评论

阅读排行榜

评论排行榜

合并DataGrid相同的行

Posted on 2006-12-20 21:39 玄铁剑 阅读(434) 评论(0)  编辑 收藏 引用 所属分类: asp.net

    private void MergeRows(DataGrid grid)
    {
        int row, icur, ispan;
        int icol = grid.Columns.Count - 1;
        int irow_count = grid.Items.Count - 1;
        string strtmp;

        for (int col = 0; col <= icol; col++)
        {
            if (grid.Columns[col].Visible == false)
                continue;
            ispan = 1;
            row = 0;
            icur = 0;
            while (row <= irow)
            {
                strtmp = grid.Items[icur].Cells[col].Text.ToString();
                row += 1;
                if (row <= irow)
                {
                    if (grid.Items[row].Cells[col].Text.ToString().Equals(strtmp))
                    {
                        ispan += 1;
                        grid.Items[icur].Cells[col].RowSpan = ispan;
                        grid.Items[row].Cells[col].Visible = false;
                    }
                    else
                    {
                        ispan = 1;
                        icur = row;
                    }
                }
            }
        }
    } 

只有注册用户登录后才能发表评论。