datagrid and columnwidth

  • Thread starter Thread starter max
  • Start date Start date
M

max

I am not being a smartass and would honestly like an explanation, if
you could take the time.

What's wrong with:

DataGrid.Column(0).Width = 30?
or
DataGrid.Column(2).Width = DataGrid.Width - _
(DataGrid.Column(0).Width + _
DataGrid.Column(1).Width) ?

Is there something wrong with simplicity?? Does this not cover all
the bases? Or possibly could it be to keep the humbled masses in there
place? Or ?

Thanks for your time,
--max
 
Max,

An in my opinion very simple sample for an extended use of the table style
that I made yesterday, and changed a little bit for this message here in the
message (when there are typos)

\\\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)
dt.LoadDataRow(New Object() {"Herfried"}, True)
dt.LoadDataRow(New Object() {"Crouchie"}, True)
dt.LoadDataRow(New Object() {"Ken"}, True)
dt.LoadDataRow(New Object() {"Jay"}, True)
'here start the sample
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 = "Names"
column.Width = 100
DataGrid1.DataSource = dt
End Sub
///

I hope this helps a little bit?

Cor
 
Well, I guess I was just being pissy this morning. Thanks for all of
the kind responses.

But I was questioning the nature of how we go about setting the column
width on grid. Seems to me that .Width or .ColumnWidth was pretty
straight forward, but, well, now, it takes seven steps to do what we
could do in an assignment. Is this progress??

Okay, maybe I'm still pissy, but enquiring minds want to know.

Thanks again for your time,
--max
 

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