只读属性设定
datagridview.ReadOnly = True
行自动追加
datagridview.AllowUserToAddRows = False
删除行允许
datagridview.AllowUserToDeleteRows = False
行幅设置
datagridview.AllowUserToResizeRows = False
datagridview.ColumnHeadersHeightSizeMode =DataGridViewColumnHeadersHeightSizeMode.DisableResizing
行表示
datagridview.RowHeadersVisible = False
行选择模式
datagridview.SelectionMode = DataGridViewSelectionMode.FullRowSelect
复数行选择
datagridview.MultiSelect = True
选择状态解除
datagridview.ClearSelection()
文字设置位置
datagridview.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
选择后行的颜色
datagridview.DefaultCellStyle.SelectionBackColor = Color.GreenYellow
datagridview.DefaultCellStyle.SelectionForeColor = Color.Black
行幅自动调整
datagridview.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill