Problem:
How can you dynamically change the alignment of Text in a cell of a DataGridView in .Net ?
Resolution:
There is an enumeration "DataGridViewContentAlignment" that allows you to set the alignment in a cell. You can use this using code such as:-
set DataGridView1::"Columns"::"Item"(0)::"DefaultCellStyle"::"Alignment"
to cDataGridViewContentAlignment::"TopCenter"
set DataGridView1::"Columns"::"Item"(1)::"DefaultCellStyle"::"Alignment"
to cDataGridViewContentAlignment::"TopCenter"
A full demo is attached to this article.




