System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle1.BackColor = Color.LightGray;
dataGridView1.EnableHeadersVisualStyles = false;
dataGridView1.DefaultCellStyle = dataGridViewCellStyle1;
dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
dataGridView1.DataSource = null; // 绑定数据
dataGridView1.AllowUserToResizeRows = true; // 禁止高度拉长,
dataGridView1.ReadOnly = true; // 只读
dataGridView1.RowHeadersVisible = false; // 禁止显示首列(即行头)
dataGridView1.AllowUserToAddRows = false; // 取消最后一行
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; // 整行选择
dataGridView1.BackgroundColor = System.Drawing.SystemColors.ButtonHighlight; // 背景色
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView1.DataSource = null;
标签:初始化,false,Windows,System,DataGridView,Forms,dataGridViewCellStyle1,dataGridView1 From: https://www.cnblogs.com/jxjy4210/p/18574096