Confused about DataGridTableStyle

  • Thread starter Thread starter iano
  • Start date Start date
I

iano

When I first saw the word style here, I immediately jumped to the
conclusion that the styles were of the Cascading Style Sheet variety.
It now looks that was the wrong conclusion.

Here is what I was attempting to do
<th style="text-align:center;font-weight:bold;> One or more
columns</th>

What would be the best way to do this for a
System.Windows.Forms.DataGrid?

Thanks,
IanO
 
Iano,

Look at this sample I just made (so watch errors)

\\\Needs only a datagrid on a form
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt As New DataTable
dt.Columns.Add("MyColumn")
dt.LoadDataRow(New Object() {"Cor"}, True)
Dim ts As New DataGridTableStyle
ts.MappingName = dt.TableName
Dim column As New DataGridTextBoxColumn
ts.GridColumnStyles.Add(column)
DataGrid1.TableStyles.Add(ts)
ts.PreferredRowHeight = 30
DirectCast(column.TextBox, DataGridTextBox).Font = _
New System.Drawing.Font("Arial", 14, FontStyle.Bold)
column.Alignment = HorizontalAlignment.Center
column.MappingName = dt.Columns(0).ColumnName
column.HeaderText = "MyName"
column.Width = 100
DataGrid1.DataSource = dt
End Sub
///
I hope this helps a little bit?

Cor
 
re: I hope this helps a little bit?
Sure does!

I have a much better idea of how the ``styles'' work.
Is it possible though to have this

column.Alignment = HorizontalAlignment.Center

only apply to the Header row?

Thanks again, Cor.
IanO
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top