E
Earl
I thought I had done this before, but I'm apparently overlooking something.
All I want to do is set the alignment of the first column to the right. The
dataset gives me 5 columns and will auto-format the grid, but I really want
to align just one column. Thus the code below. However, the app blows right
past my attempt to impose a new table style and auto-formats the grid with
everything aligned to the left (I have deleted all table styles from the
Datagrid properties, so there is no "default").
Is it possible to set alignment for one column or do ALL need to be manually
aligned? Anything else I'm overlooking?
DataGrid1.TableStyles.Clear()
Dim tblStyle As New DataGridTableStyle
tblStyle.MappingName = "History"
Dim dgColumn1 As New DataGridTextBoxColumn
Dim dgColStyleRight As DataGridColumnStyle
dgColumn1 = New DataGridTextBoxColumn
dgColumn1.Alignment = System.Windows.Forms.HorizontalAlignment.Center
tblStyle.GridColumnStyles.Add(dgColumn1)
DataGrid1.CaptionText = "History"
DataGrid1.ReadOnly = True
DataGrid1.TableStyles.Add(tblStyle)
All I want to do is set the alignment of the first column to the right. The
dataset gives me 5 columns and will auto-format the grid, but I really want
to align just one column. Thus the code below. However, the app blows right
past my attempt to impose a new table style and auto-formats the grid with
everything aligned to the left (I have deleted all table styles from the
Datagrid properties, so there is no "default").
Is it possible to set alignment for one column or do ALL need to be manually
aligned? Anything else I'm overlooking?
DataGrid1.TableStyles.Clear()
Dim tblStyle As New DataGridTableStyle
tblStyle.MappingName = "History"
Dim dgColumn1 As New DataGridTextBoxColumn
Dim dgColStyleRight As DataGridColumnStyle
dgColumn1 = New DataGridTextBoxColumn
dgColumn1.Alignment = System.Windows.Forms.HorizontalAlignment.Center
tblStyle.GridColumnStyles.Add(dgColumn1)
DataGrid1.CaptionText = "History"
DataGrid1.ReadOnly = True
DataGrid1.TableStyles.Add(tblStyle)