// Create a Custom TableStyle
DataGridTableStyle tableStyle = new DataGridTableStyle();
tableStyle.MappingName = "ArrayList";
tableStyle.HeaderFont = new Font("Verdana", 9, FontStyle.Bold);
tableStyle.HeaderForeColor = Color.OrangeRed;
int colwidth = (dataGrid1.ClientSize.Width - tableStyle.RowHeaderWidth
- SystemInformation.VerticalScrollBarWidth) / 6;
// Create a DataGridColumn, set its header text and other properties
DataGridTextBoxColumn cs = new DataGridTextBoxColumn();
cs.MappingName = "FirstName";
cs.HeaderText = "First Name";
cs.Width = colwidth;
// Add Column to GridColumnStyles
tableStyle.GridColumnStyles.Add(cs);
// Create a DataGridColumn, set its header text and other properties
cs = new DataGridTextBoxColumn();
cs.MappingName = "LastName";
cs.HeaderText = "Last Name";
cs.Width = colwidth;
// Add Column to GridColumnStyles
tableStyle.GridColumnStyles.Add(cs);
// Create a DataGridColumn, set its header text and other properties
cs = new DataGridTextBoxColumn();
cs.MappingName = "Age";
cs.HeaderText = "Age";
cs.Width = colwidth;
// Add Column to GridColumnStyles
tableStyle.GridColumnStyles.Add(cs);
// Create a DataGridColumn, set its header text and other properties
cs = new DataGridTextBoxColumn();
cs.MappingName = "Experience";
cs.HeaderText = "Exp (Years)";
cs.Width = colwidth;
// Add Column to GridColumnStyles
tableStyle.GridColumnStyles.Add(cs);
// Create a DataGridColumn, set its header text and other properties
cs = new DataGridTextBoxColumn();
cs.MappingName = "Skills";
cs.HeaderText = "Skills";
cs.Width = colwidth + colwidth;
// Add Column to GridColumnStyles
tableStyle.GridColumnStyles.Add(cs);
// Get rid of current table style
dataGrid1.TableStyles.Clear();
// Add new table style to the Grid
dataGrid1.TableStyles.Add(tableStyle);