473,387 Members | 1,542 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,387 software developers and data experts.

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 31084
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
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
by: | last post by:
How do I change the datagrid column width dynamically when the grid's being loaded? VM
0
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
by: RA | last post by:
How can I get the datagrid column width when the user changes it? Thanks
1
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
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
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
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.