我不知道,如果這也幫助別人誰谷歌搜索後,土地在這裏,我根據這一些VB代碼,我在另一個論壇中發現:
using System;
using System.Windows.Forms;
using System.Drawing;
namespace CPS
{
class gradientGrid : DataGridView
{
protected override void PaintBackground(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle gridBounds)
{
base.PaintBackground(graphics, clipBounds, gridBounds);
System.Drawing.Drawing2D.LinearGradientBrush b = new System.Drawing.Drawing2D.LinearGradientBrush(clipBounds, Color.CadetBlue, Color.AntiqueWhite, System.Drawing.Drawing2D.LinearGradientMode.Horizontal);
graphics.FillRectangle(b, clipBounds);
}
}
}
一旦你建立了這個作爲一個單獨的類它顯示在你的(VS2010)工具箱,你把它在窗體上...
此代碼對整個數據網格視圖,以便做的每一行,你可以使用RowPrePaint事件.. 。
我刪除了那段代碼,但漸變色R不適用於行。我不知道爲什麼。它似乎默認風格重寫這種風格 – Arian