-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDGVCustom.cs
52 lines (48 loc) · 2.21 KB
/
DGVCustom.cs
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
49
50
51
52
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MundoMusical.CUSTOM_CONTROLS
{
public partial class DGVCustom : System.Windows.Forms.DataGridView
{
public DGVCustom()
{
InitializeComponent();
}
protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
this.DoubleBuffered = true;
this.BackgroundColor = Color.Silver;
this.BorderStyle = BorderStyle.Fixed3D;
this.ForeColor = Color.Black;
this.ColumnHeadersDefaultCellStyle.Font = new System.Drawing.Font("Times New Roman", 12,FontStyle.Bold);
this.Font = new Font("Times New Roman", 12, FontStyle.Regular);
this.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
this.ColumnHeadersDefaultCellStyle.BackColor = Color.LightSkyBlue;
this.DefaultCellStyle = new DataGridViewCellStyle { BackColor = Color.Gainsboro,Alignment = DataGridViewContentAlignment.MiddleCenter, SelectionBackColor = Color.LightSkyBlue};
this.AlternatingRowsDefaultCellStyle = new DataGridViewCellStyle { BackColor = Color.WhiteSmoke,Alignment = DataGridViewContentAlignment.MiddleCenter };
this.ReadOnly = true;
this.RowHeadersVisible = false;
this.ScrollBars = ScrollBars.Both;
//this.AutoSizeColumnsMode = null;
//this.AllowUserToResizeColumns = false;
this.EnableHeadersVisualStyles = true;
this.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Sunken;
this.Dock = DockStyle.Fill;
this.AllowUserToAddRows = false;
this.AllowUserToResizeRows = false;
}
protected override void OnColumnAdded(DataGridViewColumnEventArgs e)
{
base.OnColumnAdded(e);
e.Column.SortMode = DataGridViewColumnSortMode.Programmatic;
}
}
}