-1
Im使用WinForms
和DataGridView
。DataGridView造型滾動條
我已經設計了應用程序以利用FlatAppearance
,並且所有外觀都正常。
我唯一的問題是試圖將Scrollbars
設置爲單個平面顏色而沒有視覺樣式。
是否有某種方法可以重寫此默認行爲?
此外,這也可以爲DataGridViews標題行?
Im使用WinForms
和DataGridView
。DataGridView造型滾動條
我已經設計了應用程序以利用FlatAppearance
,並且所有外觀都正常。
我唯一的問題是試圖將Scrollbars
設置爲單個平面顏色而沒有視覺樣式。
是否有某種方法可以重寫此默認行爲?
此外,這也可以爲DataGridViews標題行?
我會回答你的第二個問題。您可以使用此代碼,自定義頁眉的字體和顏色:
void DataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
Brush gradientBrush;
var grd = (DataGridView)sender;
//header
if (e.RowIndex == -1)
{
gradientBrush = new LinearGradientBrush(...gradientParams..);
e.CellStyle.Font = new Font(...FontParams...);
}
e.Graphics.FillRectangle(gradientBrush, e.CellBounds);
gradientBrush.Dispose();
// paint rest of cell
e.Paint(e.CellBounds, DataGridViewPaintParts.Border | DataGridViewPaintParts.ContentForeground);
e.Handled = true;
}
林不知道放哪矩形,我現在有這個 gradientBrush =新一個LinearGradientBrush(dataGridView1.DisplayRectangle,Color.Black,Color.Red ,6.5f); e.CellStyle.Font = new Font(this.Font,FontStyle.Italic); e.CellStyle.BackColor = Color.Black; – IEnumerable
字體已更改但不包含單元格標題backcolor,它仍然是默認的3D樣式 – IEnumerable
OPS抱歉。我忘記了代碼的最後幾行,因爲我刪除了很多關於其他主題的內容。 – Jonathan