一、设置DataGridView 内容居中显示,必须设置SortMode 为NotSortable,否则设置不会生效,如下为设置某列居中显示
dataGridView.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAligent.MiddleCenter;
dataGridView.Columns[0].SortMode= DataGridViewColumnSortMode.NotSortable;
dataGridView.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAligent.MiddleCenter;
dataGridView.Columns[0].SortMode= DataGridViewColumnSortMode.NotSortable;