473,782 Members | 2,507 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Pr eferredColumnWi dth = 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 6477
this should help make sure you set the width for al the col's in the
datagrid

Dim ts As New DataGridTableSt yle

ts.MappingName = "Table"

dgrMain.TableSt yles.Clear()

dgrMain.SetData Binding(dsForm, "Table")

dgrMain.TableSt yles.Add(ts)

ts.GridColumnSt yles(0).Width = 0

ts.GridColumnSt yles(1).Width = 117

ts.GridColumnSt yles(2).Width = 280

ts.GridColumnSt yles(3).Width = 83

ts.AllowSorting = True

ts.AlternatingB ackColor = Color.Lavender

ts.BackColor = Color.WhiteSmok e

ts.ForeColor = Color.MidnightB lue

ts.GridLineColo r = Color.Gainsboro

ts.HeaderBackCo lor = Color.MidnightB lue

ts.HeaderForeCo lor = Color.WhiteSmok e

ts.LinkColor = Color.Navy

ts.SelectionBac kColor = Color.Navy

ts.SelectionFor eColor = Color.Lavender

ts.ColumnHeader sVisible = True

"Mike Fellows" <mi************ *@equityhouse.c o.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.Pr eferredColumnWi dth = 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.c o.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.Pr eferredColumnWi dth = 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/vbtchformatting windowsformsdat agridvisualbasi cprimer.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********@THI Somnipack.be> wrote in message
news:3f******** *************** @reader0.news.s kynet.be...
this should help make sure you set the width for al the col's in the
datagrid

Dim ts As New DataGridTableSt yle

ts.MappingName = "Table"

dgrMain.TableSt yles.Clear()

dgrMain.SetData Binding(dsForm, "Table")

dgrMain.TableSt yles.Add(ts)

ts.GridColumnSt yles(0).Width = 0

ts.GridColumnSt yles(1).Width = 117

ts.GridColumnSt yles(2).Width = 280

ts.GridColumnSt yles(3).Width = 83

ts.AllowSorting = True

ts.AlternatingB ackColor = Color.Lavender

ts.BackColor = Color.WhiteSmok e

ts.ForeColor = Color.MidnightB lue

ts.GridLineColo r = Color.Gainsboro

ts.HeaderBackCo lor = Color.MidnightB lue

ts.HeaderForeCo lor = Color.WhiteSmok e

ts.LinkColor = Color.Navy

ts.SelectionBac kColor = Color.Navy

ts.SelectionFor eColor = Color.Lavender

ts.ColumnHeader sVisible = True

"Mike Fellows" <mi************ *@equityhouse.c o.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.Pr eferredColumnWi dth = 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
3380
by: Prateek | last post by:
Hi, How can I change the width of a column in datagrid control? TIA Prateek
1
2347
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 mode. But I have discovered that it is not enough to simply specify the column widths by way of 'HeaderStyle-Width="25px" ItemStyle-Width="25px"'-type properties inside in the <asp:BoundColumn> tags, because by default all the text boxes in edit mode...
9
3945
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 selection column on the left. I have the widths of the columns. What other values do I need to include in the DataGrid width? Thanx,
3
4266
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 of a subclassed DataGridTextBoxColum dos not seem like a practical way to do it. I have subclassed a DataGrid and overridden the OnPaint as such:
2
6414
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
2749
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 freeze.
2
10406
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 actually happens is... when the Text size is too big... the column
2
1780
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 said the style name had to be the same as the table name. Perhaps the are refering to ts1.mappingname must be the same as the table name (datagrid1.datamember) because I've read that that is how the datagrid associates a style with what it's...
2
6596
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 in the child datagrid and then go to the combobox and choose another vendor. When the new vendor is loaded nothing shows in the datagrid but the itemsource shows the info is there. Know if I click on the child cell and then click back on the...
0
9641
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10313
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.