Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Centering Column and Row Text Content in DataGridView

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?

like image 845
Anoushka Seechurn Avatar asked Dec 18 '13 09:12

Anoushka Seechurn


1 Answers

Try this.

dataGridView1.RowsDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
like image 155
Priyank Avatar answered Sep 22 '22 17:09

Priyank