Dreamine.UI.WinForms 1.0.1
Dreamine.UI.WinForms 사용자 인터페이스 기능과 구성 요소를 제공합니다.
로딩중...
검색중...
일치하는것 없음
DreamineDataGrid.cs
이 파일의 문서화 페이지로 가기
1using System.Drawing;
3
5
14public class DreamineDataGrid : DataGridView
15{
24 private int _lastClickedRow = -1;
25
34 public bool EnableClickToDeselect { get; set; }
35
45 {
46 BorderStyle = BorderStyle.None;
47 BackgroundColor = DreamineTheme.InputBackground;
48 GridColor = DreamineTheme.BorderNormal;
49 RowHeadersVisible = false;
50 AllowUserToAddRows = false;
51 AllowUserToDeleteRows = false;
52 AllowUserToResizeRows = false;
53 ReadOnly = true;
54 SelectionMode = DataGridViewSelectionMode.FullRowSelect;
55 MultiSelect = false;
56 AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
57 ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
58 ColumnHeadersHeight = 32;
59 EnableHeadersVisualStyles = false;
60 CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal;
61 Font = new Font("Segoe UI", 9.5f);
62
63 ColumnHeadersDefaultCellStyle.BackColor = DreamineTheme.NavBackground;
64 ColumnHeadersDefaultCellStyle.ForeColor = DreamineTheme.TextPrimary;
65 ColumnHeadersDefaultCellStyle.Font = new Font("Segoe UI", 9.5f, FontStyle.Bold);
66 ColumnHeadersDefaultCellStyle.SelectionBackColor = DreamineTheme.NavBackground;
67
68 DefaultCellStyle.BackColor = DreamineTheme.InputBackground;
69 DefaultCellStyle.ForeColor = DreamineTheme.TextPrimary;
70 DefaultCellStyle.SelectionBackColor = DreamineTheme.AccentBlue;
71 DefaultCellStyle.SelectionForeColor = Color.White;
72
73 AlternatingRowsDefaultCellStyle.BackColor = DreamineTheme.CardBackground;
74 AlternatingRowsDefaultCellStyle.ForeColor = DreamineTheme.TextPrimary;
75 AlternatingRowsDefaultCellStyle.SelectionBackColor = DreamineTheme.AccentBlue;
76 AlternatingRowsDefaultCellStyle.SelectionForeColor = Color.White;
77
78 CellClick += DreamineDataGrid_CellClick;
79 }
80
105 private void DreamineDataGrid_CellClick(object? sender, DataGridViewCellEventArgs e)
106 {
107 if (!EnableClickToDeselect || e.RowIndex < 0)
108 return;
109
110 if (_lastClickedRow == e.RowIndex)
111 {
112 ClearSelection();
113 CurrentCell = null;
114 _lastClickedRow = -1;
115 }
116 else
117 {
118 _lastClickedRow = e.RowIndex;
119 }
120 }
121}
void DreamineDataGrid_CellClick(object? sender, DataGridViewCellEventArgs e)
static readonly Color CardBackground
static readonly Color NavBackground
static readonly Color TextPrimary
static readonly Color BorderNormal
static readonly Color InputBackground