dataGridView1.DataSource = dbc.getDisposableAnalysis(todayFormatted);
try
{
- dataGridView1.Columns["상품명"].Width = 200;
- dataGridView1.Columns["비율"].Width = 55;
+ dataGridView1.Columns["상품명"].Width = 180;
+ dataGridView1.Columns["비율"].Width = 80;
dataGridView1.Columns["개수"].Width = 55;
- dataGridView1.Columns["매출"].Width = 80;
+ dataGridView1.Columns["매출"].Width = 105;
}
catch (Exception)
{
}
+
+ // 색상 적용
+ foreach (DataGridViewRow row in dataGridView1.Rows)
+ {
+ if (row.IsNewRow) continue; // 새 행 무시
+
+ string colorStr = row.Cells["row_color"].Value?.ToString();
+ if (!string.IsNullOrEmpty(colorStr))
+ {
+ try
+ {
+ row.DefaultCellStyle.BackColor = Color.FromName(colorStr);
+ row.DefaultCellStyle.Font = new Font(dataGridView1.Font.FontFamily, 10, FontStyle.Bold);
+ }
+ catch
+ {
+ // 유효하지 않은 색상일 경우 무시
+ }
+ }
+ }
+
+ // 색상 표기된 컬럼 숨기기 (원한다면)
+ dataGridView1.Columns["row_color"].Visible = false;
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
dataGridView1.DataSource = dbc.getDisposableAnalysis(result);
try
{
- dataGridView1.Columns["상품명"].Width = 200;
- dataGridView1.Columns["비율"].Width = 55;
+ dataGridView1.Columns["상품명"].Width = 180;
+ dataGridView1.Columns["비율"].Width = 80;
dataGridView1.Columns["개수"].Width = 55;
- dataGridView1.Columns["매출"].Width = 80;
+ dataGridView1.Columns["매출"].Width = 105;
}
catch (Exception)
{
}
+ // 색상 적용
+ foreach (DataGridViewRow row in dataGridView1.Rows)
+ {
+ if (row.IsNewRow) continue; // 새 행 무시
+
+ try
+ {
+ string colorStr = row.Cells["row_color"].Value?.ToString();
+ if (!string.IsNullOrEmpty(colorStr))
+ {
+ try
+ {
+ row.DefaultCellStyle.BackColor = Color.FromName(colorStr);
+ row.DefaultCellStyle.Font = new Font(dataGridView1.Font.FontFamily, 10, FontStyle.Bold);
+ }
+ catch
+ {
+ // 유효하지 않은 색상일 경우 무시
+ }
+ }
+ // 색상 표기된 컬럼 숨기기 (원한다면)
+ dataGridView1.Columns["row_color"].Visible = false;
+ }
+ catch
+ {
+
+ }
+ }
+
+
+
}
private void button4_Click(object sender, EventArgs e)