Change the alignment of data from datagridview


Here is the code to Change vertical and horizontal alignment of data in the single column from datagridview.

Code is useful in Windows Based C# application:

Here 0 stand for Column Index, You can change it as per your requirement.
And 'MiddleLeft' is used to set 'Vertical Alignment' of data in middle
and 'Horizontal Alignment' of data at left side.

dataGridView1.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;


Related Articles

Insert, update and delete data using DataGridView

You can use DataGridView to fetch all the data from SQL server 2005 and then perform insert, update and delete directly in gridview then make save changes all at once.(in window application(C#)).

More articles: Change alignment DataGridView

Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: