C# DataGridViewにスタイル適用(´・ω・)ス
DataGridViewには日付やら金額やら格納する時にスタイルを適用したい(´・ω・)ス
そのメモ(´・ω・)ス
//月年日
// いくつか適用させるからDataGridViewCellStyle クラスのインスタンスを用意(´・ω・)ス
DataGridViewCellStyle 年月日 = new DataGridViewCellStyle();
年月日.Format = @"####年##月##日"; //年月日
//例(´・ω・)ス 0始まりの1と2
dataGridView1.Columns[1].DefaultCellStyle = 年月日;
dataGridView1.Columns[2].DefaultCellStyle = 年月日;
//金額
DataGridViewCellStyle 金額 = new DataGridViewCellStyle();
金額.Alignment = DataGridViewContentAlignment.MiddleRight; //右寄せ
金額.Format = @"#,##0"; //三桁でカンマ
//例(´・ω・)ス 0始まりの37と38
dataGridView1.Columns[37].DefaultCellStyle = 金額;
dataGridView1.Columns[38].DefaultCellStyle = 金額;
そんなメモ(´・ω・)ス
そのメモ(´・ω・)ス
//月年日
// いくつか適用させるからDataGridViewCellStyle クラスのインスタンスを用意(´・ω・)ス
DataGridViewCellStyle 年月日 = new DataGridViewCellStyle();
年月日.Format = @"####年##月##日"; //年月日
//例(´・ω・)ス 0始まりの1と2
dataGridView1.Columns[1].DefaultCellStyle = 年月日;
dataGridView1.Columns[2].DefaultCellStyle = 年月日;
//金額
DataGridViewCellStyle 金額 = new DataGridViewCellStyle();
金額.Alignment = DataGridViewContentAlignment.MiddleRight; //右寄せ
金額.Format = @"#,##0"; //三桁でカンマ
//例(´・ω・)ス 0始まりの37と38
dataGridView1.Columns[37].DefaultCellStyle = 金額;
dataGridView1.Columns[38].DefaultCellStyle = 金額;
そんなメモ(´・ω・)ス