首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

怎么修改DataGridView某一列的边框样式

2013-09-17 
如何修改DataGridView某一列的边框样式例如我想把DataGridView中的第4列的左边框网格线去掉,请高手指点,结

如何修改DataGridView某一列的边框样式
例如我想把DataGridView中的第4列的左边框网格线去掉,请高手指点,结案立即给分。
[解决办法]
思路和这个类似
http://blog.csdn.net/scutliu/article/details/5643288
[解决办法]
动态构建DataGridView动态加载列
其余的设计自己想怎么控制就怎么控制了
[解决办法]
http://forums.codeguru.com/showthread.php?415930-DataGridView-Merging-Cells
[解决办法]
CellPainting事件中,自己重绘单元格就可以了
[解决办法]
那不就是相当于合并第三列与第四列吗?

[解决办法]

引用:
给出示例代码吧


            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;
            }



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

热点排行