Datagridview alignment does not work

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • srcfreitas
    New Member
    • Apr 2010
    • 2

    #1

    Datagridview alignment does not work

    Hi, I'm trying to align datagridview columns at once to middlecenter. It works for the first column and does not for the others. I suspect it's a matter of the datasource property which is bind to a datatable which catches data from a
    SQL Server table. Below is my simple code and I thought that after this code runs I would have every column aligned to middlecenter:

    With Datagridview

    .AutoSizeColumn sMode = DataGridViewAut oSizeColumnsMod e.DisplayedCell s

    With .ColumnHeadersD efaultCellStyle
    .Alignment = DataGridViewCon tentAlignment.M iddleCenter
    End With

    With .RowsDefaultCel lStyle
    .Alignment = DataGridViewCon tentAlignment.M iddleCenter
    End With

    .ScrollBars = ScrollBars.Hori zontal

    End With


    Tks,
    Rubens
  • semomaniz
    Recognized Expert New Member
    • Oct 2007
    • 210

    #2
    set the horizontalalign property of gridview rowstyle to center. That should do it.

    Comment

    • srcfreitas
      New Member
      • Apr 2010
      • 2

      #3
      Thank you but it does not work because

      I am working with the new DataGridView and your answer applies to the former GridView. If you have any idea about how to solve this with the DataGridView new control I'd appreciate a lot. Thank you.
      SRCFreitas

      Comment

      Working...