Centering Column and Row Text Content in DataGridView

Viewed 19010

I want to center the content of my Columns and Rows on DataGridView.

Is there a way of doing this by specifying the Column name, like:

dataGridView1.Columns["CustomerName"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; 

I want this to be applied to all the Columns of my DataGridView (which is completely coded programmatically).

How can I do this?

2 Answers
Related