DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn(); col.HeaderText = "Column Name"; col.Name = "column1"; dataGridView1.Columns.Add(col);
DataGridViewTextBoxColumn col = (DataGridViewTextBoxColumn)dataGridView1.Columns["column1"]; col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; col.DefaultCellStyle.Font = new Font("Arial", 12, FontStyle.Bold);In this example, the DataGridViewTextBoxColumn named "column1" is retrieved and its alignment is changed to centered. The font is also changed to Arial 12pt bold. These examples are part of the System.Windows.Forms namespace, which is included in the .NET Framework Class Library.