我需要繪製DataGridView單元格的背景,而不是它的Content.But,而我正在繪畫時也繪製它的內容。請幫助我。如何僅繪製DataGridView的單元格背景而不是其內容?
我的代碼是這樣的。
private void Daywisegrid_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
if (e.RowIndex == 0)
{
using (Brush gridBrush = new SolidBrush(this.Daywisegrid.GridColor))
{
using (Brush backColorBrush = new SolidBrush(e.CellStyle.BackColor))
{
using (Pen gridLinePen = new Pen(gridBrush))
{
// Clear cell
e.Graphics.FillRectangle(backColorBrush, e.CellBounds);
//Bottom line drawing
e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left, e.CellBounds.Bottom-1 , e.CellBounds.Right, e.CellBounds.Bottom-1);
e.Handled = true;
}
}
}
}