469,160 Members | 1,990 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,160 developers. It's quick & easy.

datagrid and columnwidth

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
Nov 21 '05 #1
4 1285
<max> schrieb:
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?


I am not very familar with the datagrid, but you may want to take a look at
the page referenced below:

<URL:http://msdn.microsoft.com/library/en-us/dv_vstechart/html/vbtchformattingwindowsformsdatagridvisualbasicprim er.asp>
-> "Setting Column Width"

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2
Are You Using GridColumnStyle
If not , try using that

HTH
rawCoder

<max> wrote in message news:n2********************************@4ax.com...
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

Nov 21 '05 #3
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
Nov 21 '05 #4
max
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
On Wed, 20 Apr 2005 09:49:05 -0600, max wrote:
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


Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Hannes | last post: by
reply views Thread by Hannes | last post: by
1 post views Thread by BC | last post: by
1 post views Thread by Willem | last post: by
2 posts views Thread by Andrew Baker | last post: by
4 posts views Thread by Paul Ilacqua | last post: by
1 post views Thread by Price Brattin | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.