要可以运行的 DataGridView 横向合并单元格  谢谢[email protected]

解决方案 »

  1.   

    http://blog.csdn.net/csharp_start/archive/2007/09/30/1808000.aspx
      

  2.   

    我以前也遇到过lz一样的问题,但是还是处理不好,不能重新 dataRow dr = d.newRow;  dr[0]=....  d.rows.add.(dr);
       呵呵 这样貌似是不行。还是跟上面的行是一样的列数。但是 除了 指定的两个列, 其他的列的值都是空  的!学习了`~~~~~
      

  3.   


            #region 合并DataGrid显示竖向合并,改一下i和j的定义就可以 
            public void SpanDataGrid(DataGrid dataGrid, int compareColumn, int sColumn, int pColumn, string label,bool wrap)
            {
                int rowSpan;
                int i, j;
                string strTemp;            if (dataGrid.Items.Count > 0)
                {
                    for (int t = sColumn; t < pColumn; t++)
                    {
                        strTemp = ((Label)dataGrid.Items[compareColumn].Cells[0].FindControl("label")).Text;
                        dataGrid.Items[0].Cells[t].RowSpan = 1;
                        j = 0;
                        for (i = 1; i < dataGrid.Items.Count; i++)
                        {
                            if (((Label)dataGrid.Items[i].Cells[compareColumn].FindControl("label")).Text == strTemp)
                            {
                                dataGrid.Items[i].Cells[t].Visible = false;
                                dataGrid.Items[j].Cells[t].RowSpan++;
                            }
                            else
                            {
                                strTemp = ((Label)dataGrid.Items[i].Cells[compareColumn].FindControl("label")).Text;
                                j = i;
                                dataGrid.Items[i].Cells[t].RowSpan = 1;
                            }
                        }
                    }//i = j;
                }
                dataGrid.Columns[compareColumn].Visible = wrap;
            }
            #endregion
      

  4.   

    我是要 DataGridView 的合并行  您提供的这个好像不行、
      

  5.   

    http://download.csdn.net/source/531194
      

  6.   

    。。 我是要横向合并DataGridView 的  而且是要有代码的  怎么到处找都没有  不是有很多BUG  就是根本找不到    难道都是用第三方控件的吗?