473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Individual Datagrid Column Width

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
3 6443
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
* "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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Prateek | last post by:
Hi, How can I change the width of a column in datagrid control? TIA Prateek
1
by: TB | last post by:
Hi All: I have this datagrid where space is very tight, and therefore I have to make sure that everything fits within a fixed screen width regardless of whether I am in list mode or in edit...
9
by: web1110 | last post by:
Hi y'all, I have resized the columns in a DataGrid and I want to set the width of the DataGrid to fit the columns. Just summing the column widths is too short due to the grid and gray row...
3
by: Richard | last post by:
I have a requirement to put a GDI style circle or rectangle border around the selected row of a datagrid/ It will overlap into the row above and below the selected row. Doing this in a the OnPaint...
2
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
6
by: Agnes | last post by:
I understand it is impossible, but still curious to know "Can I freeze several column in the datagrid, the user can only scroll the first 3 columns (not verical), for the rest of the coulumn, it is...
2
by: Charleees | last post by:
Hi all, I have a DataGrid with Template Columns..... There are LAbels,Linkbuttons in the Single Row.. I have to set the Constant Column width for those Template Columns in Grid... Wat...
2
by: cj | last post by:
I was looking over some of my 2003 code today (see below) that loads a foxpro table via oledb connection. I used a sub "autosizecolumns" I found on the web but I never quite understood why they...
2
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.