2010-02-01 45 views

回答

14

不能,它用用户在首选主题中选择的颜色绘制,在控制面板的“显示”小程序中选择。覆盖用户偏好是有风险的,但您可以自己绘制它。将DGV的BorderStyle属性设置为None,并在窗体的OnPaintBackground()方法中自己绘制边框。例如:

protected override void OnPaintBackground(PaintEventArgs e) { 
    base.OnPaintBackground(e); 
    Rectangle rc = new Rectangle(dataGridView1.Left - 1, dataGridView1.Top - 1, 
    dataGridView1.Size.Width + 1, dataGridView1.Size.Height + 1); 
    e.Graphics.DrawRectangle(Pens.Fuchsia, rc); 
}