//// 设定列标题的宽度可以自由调整 //DataGridViewCheckBoxColumn column = new DataGridViewCheckBoxColumn();
\n
////AutoSizeColumnsMode指定如何设置列宽
//setGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
////AutoSizeRowsMode指定如何设置行高
//setGridView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
\n
//setGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
//// 设定行标题的宽度可以自由调整
//setGridView.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;
\n
//setGridView.Columns.Insert(0, column);
\n
//列标题文本居中 DataGridViewColumn控件中的列
foreach (DataGridViewColumn col in setGridView.Columns)
{
col.SortMode = DataGridViewColumnSortMode.NotSortable;
}
setGridView.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
\n
//行高度 DataGridViewRow控件中的行
foreach (DataGridViewRow rows in setGridView.Rows)
{
rows.Height = 15;
}
\n
//单击选取整行 SelectionMode指定如何设置单元格 DataGridViewSelectionMode可以如何选定单元格
setGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; //FullRowSelect通过单击表头和所包含的单元格选取整行
//设定不显示DateGridView的最左一列
setGridView.RowHeadersVisible = false;
\n