例如我想把DataGridView中的第4列的左边框网格线去掉,请高手指点,结案立即给分。

解决方案 »

  1.   

    思路和这个类似
    http://blog.csdn.net/scutliu/article/details/5643288
      

  2.   

    动态构建DataGridView动态加载列
    其余的设计自己想怎么控制就怎么控制了
      

  3.   

    http://forums.codeguru.com/showthread.php?415930-DataGridView-Merging-Cells
      

  4.   

    CellPainting事件中,自己重绘单元格就可以了
      

  5.   


                if (e.RowIndex != -1 && e.ColumnIndex == 4)
                {
                    Brush gridBrush = new SolidBrush(dataGridView1.GridColor);
                    using (Pen gridLinePen = new Pen(gridBrush))
                    {
                        e.Graphics.FillRectangle(new SolidBrush(Color.White), e.CellBounds);
                        e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left,
                         e.CellBounds.Bottom - 1, e.CellBounds.Right,
                         e.CellBounds.Bottom - 1);
                        if (e.Value != null)
                        {
                            e.Graphics.DrawString((string)e.Value, e.CellStyle.Font, new SolidBrush(Color.Black), e.CellBounds.X + 2, e.CellBounds.Y + 5, StringFormat.GenericDefault);
                        }
                    }
                    e.Handled = true;
                }代码
      

  6.   

    感谢回复!把以上代码放在CellPainting事件中,还是不行。
      

  7.   

    看来LZ是伸手党,不知道是不会分析还是懒得分析,你那是一个icon,人家给的代码是DrawString,你改个方法不就行了吗
      

  8.   

    使用DrawString时,其它数据类型肯定是要转换成字符型的。我的问题是动态加载列时出了点问题。不过现在已经解决了,多谢yyantifa的指点!感谢所有回复此贴的人。