473,494 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DataGrid Column Width

How do I set the column width of a column in a DataGrid programatically (in
ASP.NET web pages)?

I understand I may have to use DataGridTableStyle, but I can't get this to
work with web pages.

Any help would be appreciated.
Nov 15 '05 #1
3 31094
you can programmatically change width of the column like this,

datagrid1.Columns(0).ItemStyle.Width.Pixel(150)

or

datagrid1.Columns(0).ItemStyle.Width = new Unit(150,UnitType.Pixel)
--
Saravana
Microsoft India Community Star,
MCAD,SE,SD,DBA.
"frank" <fr***@frank.com> wrote in message
news:#m**************@TK2MSFTNGP12.phx.gbl...
How do I set the column width of a column in a DataGrid programatically (in ASP.NET web pages)?

I understand I may have to use DataGridTableStyle, but I can't get this to
work with web pages.

Any help would be appreciated.

Nov 15 '05 #2
Hi Frank,

You can use DataGrid.Columns[X].ItemStyle.Width , here goes an example:
this.locationgrid.Columns[2].Visible = this.locationgrid.Columns[3].Visible
= false;

this.locationgrid.Columns[1].ItemStyle.Width= 460;

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"frank" <fr***@frank.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
How do I set the column width of a column in a DataGrid programatically (in ASP.NET web pages)?

I understand I may have to use DataGridTableStyle, but I can't get this to
work with web pages.

Any help would be appreciated.

Nov 15 '05 #3
Just remember, that whatever you do in the code, meaning whatever HTML it
produces, a browser on client's machine will consider it as a recomendation
rather than an instruction.

Since you can hardly be sure what width the browser will assign to your
columns, it's not a good idea to rely on exact column width in your design.

Eliyahu

"Saravana" <sa******@sct.co.in> wrote in message
news:e$**************@TK2MSFTNGP12.phx.gbl...
you can programmatically change width of the column like this,

datagrid1.Columns(0).ItemStyle.Width.Pixel(150)

or

datagrid1.Columns(0).ItemStyle.Width = new Unit(150,UnitType.Pixel)
--
Saravana
Microsoft India Community Star,
MCAD,SE,SD,DBA.
"frank" <fr***@frank.com> wrote in message
news:#m**************@TK2MSFTNGP12.phx.gbl...
How do I set the column width of a column in a DataGrid programatically

(in
ASP.NET web pages)?

I understand I may have to use DataGridTableStyle, but I can't get this to work with web pages.

Any help would be appreciated.


Nov 15 '05 #4

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

Similar topics

3
366
by: Eva | last post by:
How do i indivually change the width of a datagrid coloumn? I am currently using the PrefferedColoumnWidth property, but due to space restrictions i do not want all the columns at the same...
1
11585
by: | last post by:
How do I change the datagrid column width dynamically when the grid's being loaded? VM
0
806
by: Randy | last post by:
Hello, I'm trying to find out if there is a way to set a DataGrid column width (or tableStyle column width) to be auto-expanded to encompass the widest text in that column...to be auto-expanded...
0
1024
by: RA | last post by:
How can I get the datagrid column width when the user changes it? Thanks
1
3234
by: Amos | last post by:
Can I add a column to the datagrid and also resize it? I add them like this: DataTableAddress.Columns.Add("Col1", typeof(string)); DataTableAddress.Columns.Add("Col2", typeof(string));...
2
2696
by: nj | last post by:
I am trying to set the width of a single column in the datagrid. What is happening is the column seems to stretch to try to accomodate the length of the data contained in it. I want to have it only x...
3
6451
by: Mike Fellows | last post by:
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...
1
3176
by: salih ataoz | last post by:
i have a form1 and i put Datagrid1 on it and i want to change its column width and row hight ex: datagrid1.column(0).width=200 datagrid1.row(0).width=100 or datagrid1.allcolumnwidth=200
0
1402
by: Claire | last post by:
Hi, Visual Studio 2003 The application Im writing is skinned and therefore i need to be able to write my own code for manipulating and drawing headers for a data grid outside of the control. I...
3
2032
by: Francois | last post by:
Hello, How can I size my text to fit in a datagrid column ? I do not want the datagrid go multiline. I am using WEB Forms, not windows form, so CreateGraphics ans MesasureString do not work....
0
7157
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,...
0
7195
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...
0
5453
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,...
1
4889
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4579
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
3088
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
1400
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 ...
1
644
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
285
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...

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.