We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Align text in columns and only getting it in headers?

I can only align the headers with this code I can''t seem to align the data in the rest of the grid. Please help! I am trying what I have seen posted out there here is my procedure... Private Sub AddCellFormattingColumnStyles2(ByVal grid As DataGrid, ByVal handler As FormatCellEventHandler) Dim ts As DataGridTableStyle ts = New DataGridTableStyle Dim dt As DataTable dt = CType(grid.DataSource, DataTable) ts.MappingName = dt.TableName Dim j As Integer j = 0 Do While (j < dt.Columns.Count) Dim cs As DataGridFormattableTextBoxColumn cs = New DataGridFormattableTextBoxColumn(j) cs.Alignment = HorizontalAlignment.Right cs.MappingName = dt.Columns(j).ColumnName cs.HeaderText = dt.Columns(j).ColumnName ''cs.Alignment = HorizontalAlignment.Right ''cs.Width = -1 AddHandler cs.SetCellFormat, handler ts.GridColumnStyles.Add(cs) j = (j + 1) Loop grid.TableStyles.Clear() grid.TableStyles.Add(ts) Dim z As Int32 z = 0 For z = 0 To dt.Columns.Count - 1 grid.TableStyles(0).GridColumnStyles(z).ReadOnly = True Select Case z Case 0 grid.TableStyles(0).GridColumnStyles(z).Width = 250 ''grid.TableStyles(0).GridColumnStyles(z).Alignment = HorizontalAlignment.Right Case Else grid.TableStyles(0).GridColumnStyles(z).Width = 150 ''grid.TableStyles(0).GridColumnStyles(z).Alignment = HorizontalAlignment.Right End Select Next grid.TableStyles(0).AllowSorting = False grid.TableStyles(0).SelectionBackColor = System.Drawing.Color.Gold End Sub

1 Reply

AD Administrator Syncfusion Team May 23, 2004 04:15 PM UTC

This forum is for posts regarding our Essential Grid.

Live Chat Icon For mobile
Up arrow icon