-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGridStyles.cs
More file actions
48 lines (40 loc) · 1.74 KB
/
GridStyles.cs
File metadata and controls
48 lines (40 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using System.Windows.Forms;
namespace SchedulingApp
{
public static class GridStyles
{
public static void ApplyStandardStyle(DataGridView grid)
{
grid.AutoGenerateColumns = true;
grid.EnableHeadersVisualStyles = false;
grid.ColumnHeadersDefaultCellStyle = new DataGridViewCellStyle();
grid.RowHeadersDefaultCellStyle = new DataGridViewCellStyle();
grid.RowsDefaultCellStyle = new DataGridViewCellStyle();
grid.AlternatingRowsDefaultCellStyle = new DataGridViewCellStyle();
grid.Font = new Font("Arial", 10, FontStyle.Regular);
// Column headers
grid.ColumnHeadersDefaultCellStyle.BackColor = Color.Black;
grid.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
grid.ColumnHeadersDefaultCellStyle.Font = new Font(grid.Font, FontStyle.Bold);
// Row headers
grid.RowHeadersDefaultCellStyle.BackColor = Color.DarkGray;
grid.RowHeadersDefaultCellStyle.ForeColor = Color.White;
// Rows
grid.RowsDefaultCellStyle.BackColor = Color.White;
grid.RowsDefaultCellStyle.ForeColor = Color.Black;
grid.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGray;
// Selection
grid.DefaultCellStyle.SelectionBackColor = Color.DarkRed;
grid.DefaultCellStyle.SelectionForeColor = Color.White;
// Background / border
grid.BackgroundColor = Color.Black;
grid.BorderStyle = BorderStyle.None;
}
}
}