2010-02-01 47 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); 
}