473,467 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Setting Bound Grid Column Width

I thought there should be simple way of setting the column width in the
a DataGrid. I've set up a table style (properties tab) that lengthen the
columns,
but I can't seem to bind this table style to the grid (or it's columns I
guess). No
matter what I do the grid keeps a standard column size for each column.
Can anyone throw me a bone here?
Thanks.
Nov 15 '05 #1
2 1667
It's probably the columnmappings. Are you adding the TableStyle and
ColumnStyle before you bind or after: Try this....

dg.SuspendLayout()

Const ng As String = "NOT GIVEN"

Dim tsMain As New DataGridTableStyle

tsMain.MappingName = AllData.Tbl_Job_Tracking.TableName

'Work Type Column

Dim csWorkType As DataGridTextBoxColumn = New DataGridTextBoxColumn

csWorkType.MappingName = AllData.Tbl_Job_Tracking.Columns(0).ColumnName

csWorkType.HeaderText = "Work Type"

csWorkType.Width = 70

tsMain.GridColumnStyles.Add(csWorkType)

'Job Number Column

Dim csJobNumber As New DataGridTextBoxColumn

csJobNumber.MappingName = AllData.Tbl_Job_Tracking.Columns(1).ColumnName

csJobNumber.HeaderText = "Job #"

csJobNumber.Width = 65

csJobNumber.NullText = ng

tsMain.GridColumnStyles.Add(csJobNumber)

tsMain.GridColumnStyles.Add(csDeleteResp)

dg.TableStyles.Add(tsMain)

dg.ResumeLayout()

"Tim Nelson" <ti***************@softhome.net> wrote in message
news:#m**************@TK2MSFTNGP10.phx.gbl...
I thought there should be simple way of setting the column width in the
a DataGrid. I've set up a table style (properties tab) that lengthen the
columns,
but I can't seem to bind this table style to the grid (or it's columns I
guess). No
matter what I do the grid keeps a standard column size for each column.
Can anyone throw me a bone here?
Thanks.

Nov 15 '05 #2
William,
Thanks for the reply. I thought I could do this at design time and wouldn't
need to resort to my own code to do this. I basically have two fields
from a table one 40 characters and one 10 characters. I just want to
column that holds the 40 character to be lengthened so it displays
the whole value. I will try what you said. Thanks.

"William Ryan eMVP" <do********@comcast.nospam.net> wrote in message
news:uk****************@TK2MSFTNGP10.phx.gbl...
It's probably the columnmappings. Are you adding the TableStyle and
ColumnStyle before you bind or after: Try this....

dg.SuspendLayout()

Const ng As String = "NOT GIVEN"

Dim tsMain As New DataGridTableStyle

tsMain.MappingName = AllData.Tbl_Job_Tracking.TableName

'Work Type Column

Dim csWorkType As DataGridTextBoxColumn = New DataGridTextBoxColumn

csWorkType.MappingName = AllData.Tbl_Job_Tracking.Columns(0).ColumnName

csWorkType.HeaderText = "Work Type"

csWorkType.Width = 70

tsMain.GridColumnStyles.Add(csWorkType)

'Job Number Column

Dim csJobNumber As New DataGridTextBoxColumn

csJobNumber.MappingName = AllData.Tbl_Job_Tracking.Columns(1).ColumnName

csJobNumber.HeaderText = "Job #"

csJobNumber.Width = 65

csJobNumber.NullText = ng

tsMain.GridColumnStyles.Add(csJobNumber)

tsMain.GridColumnStyles.Add(csDeleteResp)

dg.TableStyles.Add(tsMain)

dg.ResumeLayout()

"Tim Nelson" <ti***************@softhome.net> wrote in message
news:#m**************@TK2MSFTNGP10.phx.gbl...
I thought there should be simple way of setting the column width in the
a DataGrid. I've set up a table style (properties tab) that lengthen the columns,
but I can't seem to bind this table style to the grid (or it's columns I
guess). No
matter what I do the grid keeps a standard column size for each column.
Can anyone throw me a bone here?
Thanks.


Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: VB Programmer | last post by:
I have a datagrid which is bound to a datatable that I create on the fly. How do I set the width of each column via code? Ex: Column 1 is always 100, Column 2 is always 250, etc... Thanks!
0
by: Reza Nabi | last post by:
Dear All: Banckgroud: I have a datagrid which lives inside a repeater. Which is working fine. What i need is to dyanamically set the column width of the grid (which lieves inside the repeater)....
4
by: Paul | last post by:
Hi! When I add a bound column programatically, like: BoundColumn bc = new BoundColumn(); bc.DataField = "myField"; bc.SortExpression = "myField"; myGrid.Columns.Add(bc); the SortCommand...
1
by: jimb | last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I can't read it. Anybody have a working example of a dropdownlist in an editable grid? Thanks. -- .....
4
by: Rich | last post by:
Hello, I have a one datagrid that will be based on different datatables. One datatable may have 7 columns, another 15... With the tables that have more columns, I have been manually dragging...
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...
6
by: Romulo NF | last post by:
Greetings again to everyone, Im back to show this grid componenet i´ve developed. With this grid you can show the data like a normal table, remove the rows that you need, add rows, import data,...
2
by: skanemupp | last post by:
so my little calculator works perfectly now. just having some trouble with the layout. this whole tkinter-thing seems to be more tricky than it should be. how can i make the 4 column of buttons...
1
by: Francesco Bochicchio | last post by:
Il Mon, 18 Aug 2008 12:15:10 +0100, dudeja.rajat ha scritto: Uhm, I don't think you should use the grid manager to obtain a window like that. The grid manager is for equally distributing...
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
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,...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.