如何设置datagridviews中其中几列的对齐方式?
默认全部是左对齐,我想让其中2列数字列设置成右对齐。列表头对齐方式不变!
[解决办法]
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (e.RowIndex > -1) { if (e.ColumnIndex == 0 || e.ColumnIndex == 1) e.CellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; } }