By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,684 Members | 1,338 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,684 IT Pros & Developers. It's quick & easy.

Individual Datagrid Column Width

P: n/a
Im trying to set the column width of individual datgrid columns
I can set the column widths of all the columns at once using

Me.DataGrid1.PreferredColumnWidth = 100

But I am unable to set the individual column widths

Also the source from where my data is coming from the first
column contains a date and time i.e. 01/01/2003 12:00:00
but within the datagrid it displays 01/01/2003 and i need it
to also show the time

Any help with this would be greatly appreciated

Regards

Michael Fellows
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
this should help make sure you set the width for al the col's in the
datagrid

Dim ts As New DataGridTableStyle

ts.MappingName = "Table"

dgrMain.TableStyles.Clear()

dgrMain.SetDataBinding(dsForm, "Table")

dgrMain.TableStyles.Add(ts)

ts.GridColumnStyles(0).Width = 0

ts.GridColumnStyles(1).Width = 117

ts.GridColumnStyles(2).Width = 280

ts.GridColumnStyles(3).Width = 83

ts.AllowSorting = True

ts.AlternatingBackColor = Color.Lavender

ts.BackColor = Color.WhiteSmoke

ts.ForeColor = Color.MidnightBlue

ts.GridLineColor = Color.Gainsboro

ts.HeaderBackColor = Color.MidnightBlue

ts.HeaderForeColor = Color.WhiteSmoke

ts.LinkColor = Color.Navy

ts.SelectionBackColor = Color.Navy

ts.SelectionForeColor = Color.Lavender

ts.ColumnHeadersVisible = True

"Mike Fellows" <mi*************@equityhouse.co.uk.SPAM> wrote in message
news:kY**************@newsfep1-gui.server.ntli.net...
Im trying to set the column width of individual datgrid columns
I can set the column widths of all the columns at once using

Me.DataGrid1.PreferredColumnWidth = 100

But I am unable to set the individual column widths

Also the source from where my data is coming from the first
column contains a date and time i.e. 01/01/2003 12:00:00
but within the datagrid it displays 01/01/2003 and i need it
to also show the time

Any help with this would be greatly appreciated

Regards

Michael Fellows

Nov 20 '05 #2

P: n/a
* "Mike Fellows" <mi*************@equityhouse.co.uk.SPAM> scripsit:
Im trying to set the column width of individual datgrid columns
I can set the column widths of all the columns at once using

Me.DataGrid1.PreferredColumnWidth = 100

But I am unable to set the individual column widths


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

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #3

P: n/a
Thanks That worked great
Mike Fellows

"EricJ" <er********@THISomnipack.be> wrote in message
news:3f***********************@reader0.news.skynet .be...
this should help make sure you set the width for al the col's in the
datagrid

Dim ts As New DataGridTableStyle

ts.MappingName = "Table"

dgrMain.TableStyles.Clear()

dgrMain.SetDataBinding(dsForm, "Table")

dgrMain.TableStyles.Add(ts)

ts.GridColumnStyles(0).Width = 0

ts.GridColumnStyles(1).Width = 117

ts.GridColumnStyles(2).Width = 280

ts.GridColumnStyles(3).Width = 83

ts.AllowSorting = True

ts.AlternatingBackColor = Color.Lavender

ts.BackColor = Color.WhiteSmoke

ts.ForeColor = Color.MidnightBlue

ts.GridLineColor = Color.Gainsboro

ts.HeaderBackColor = Color.MidnightBlue

ts.HeaderForeColor = Color.WhiteSmoke

ts.LinkColor = Color.Navy

ts.SelectionBackColor = Color.Navy

ts.SelectionForeColor = Color.Lavender

ts.ColumnHeadersVisible = True

"Mike Fellows" <mi*************@equityhouse.co.uk.SPAM> wrote in message
news:kY**************@newsfep1-gui.server.ntli.net...
Im trying to set the column width of individual datgrid columns
I can set the column widths of all the columns at once using

Me.DataGrid1.PreferredColumnWidth = 100

But I am unable to set the individual column widths

Also the source from where my data is coming from the first
column contains a date and time i.e. 01/01/2003 12:00:00
but within the datagrid it displays 01/01/2003 and i need it
to also show the time

Any help with this would be greatly appreciated

Regards

Michael Fellows


Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.