Private colBoolStyle As DataGridBoolColumn
Private stydgFailStatist As DataGridTableStyle
Private styTextCol As DataGridTextBoxColumn
colBoolStyle = New DataGridBoolColumn
colBoolStyle.Alignment = HorizontalAlignment.Center
colBoolStyle.HeaderText = "維修標記"
colBoolStyle.MappingName = "RepairResult"
colBoolStyle.NullText = ""
colBoolStyle.ReadOnly = False
colBoolStyle.Width = 60
stydgFailStatist.GridColumnStyles.Add(colBoolStyle)
styTextCol = New DataGridTextBoxColumn
styTextCol.Alignment = HorizontalAlignment.Left
styTextCol.HeaderText = "數量"
styTextCol.MappingName = "FailCount"
styTextCol.NullText = ""
styTextCol.ReadOnly = False
styTextCol.Width = 60
stydgFailStatist.GridColumnStyles.Add(styTextCol)
stydgFailStatist.AllowSorting = False
stydgFailStatist.MappingName = "DataList"
stydgFailStatist.BackColor = System.Drawing.Color.FromArgb(242, 255, 242)
stydgFailStatist.PreferredRowHeight = 15
stydgFailStatist.ReadOnly = False
stydgFailStatist.RowHeaderWidth = 10
datagrid1.TableStyles.Add(stydgFailStatist)
datagrid1.ReadOnly = False
自己定義datagrid的風格!想怎樣就怎樣