By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,106 Members | 1,403 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,106 IT Pros & Developers. It's quick & easy.

Datagrid col width

P: n/a
Hi,

How can I change the width of a column in datagrid control?

TIA
Prateek
Jul 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Assume your are talking about Win form DataGrid.

If you haven't define a TableStyle in DataGrid, defined one. Then,

DataGrid.TableStyle[index].GridColumnStyle[index].Width=100

"Prateek" <hi@amy.com> wrote in message news:ut**************@tk2msftngp13.phx.gbl...
Hi,

How can I change the width of a column in datagrid control?

TIA
Prateek
Jul 21 '05 #2

P: n/a
Thanks for reply.
However, I am referring to the web form datagrid.
Please let me know.

Thanks for any help u can provide

"Norman Yuan" <no********@RemoveThis.shaw.ca> wrote in message news:7MgLb.26995$ts4.12086@pd7tw3no...
Assume your are talking about Win form DataGrid.

If you haven't define a TableStyle in DataGrid, defined one. Then,

DataGrid.TableStyle[index].GridColumnStyle[index].Width=100

"Prateek" <hi@amy.com> wrote in message news:ut**************@tk2msftngp13.phx.gbl...
Hi,

How can I change the width of a column in datagrid control?

TIA
Prateek
Jul 21 '05 #3

P: n/a
Look into below object chain:

DataGrid-->Columns(DataGridColumn)-->ItemStyle(TableItemStyle)->Width

So,

MyGrid.Columns[index].ItemStyle.Width=100
"Prateek" <hi@amy.com> wrote in message news:eG**************@TK2MSFTNGP12.phx.gbl...
Thanks for reply.
However, I am referring to the web form datagrid.
Please let me know.

Thanks for any help u can provide

"Norman Yuan" <no********@RemoveThis.shaw.ca> wrote in message news:7MgLb.26995$ts4.12086@pd7tw3no...
Assume your are talking about Win form DataGrid.

If you haven't define a TableStyle in DataGrid, defined one. Then,

DataGrid.TableStyle[index].GridColumnStyle[index].Width=100

"Prateek" <hi@amy.com> wrote in message news:ut**************@tk2msftngp13.phx.gbl...
Hi,

How can I change the width of a column in datagrid control?

TIA
Prateek
Jul 21 '05 #4

P: n/a
It doesn't work. The line below does not compile:

MyGrid.Columns[index].ItemStyle.Width=100

And when I write:

MyGrid.Columns[index].ItemStyle.Width= Unit.Pixel(10) or new Unit(10)

This gives a run time error "Index out of range"

Please help!!
"Norman Yuan" <no********@RemoveThis.shaw.ca> wrote in message news:5AjLb.28257$ts4.932@pd7tw3no...
Look into below object chain:

DataGrid-->Columns(DataGridColumn)-->ItemStyle(TableItemStyle)->Width

So,

MyGrid.Columns[index].ItemStyle.Width=100
"Prateek" <hi@amy.com> wrote in message news:eG**************@TK2MSFTNGP12.phx.gbl...
Thanks for reply.
However, I am referring to the web form datagrid.
Please let me know.

Thanks for any help u can provide

"Norman Yuan" <no********@RemoveThis.shaw.ca> wrote in message news:7MgLb.26995$ts4.12086@pd7tw3no...
Assume your are talking about Win form DataGrid.

If you haven't define a TableStyle in DataGrid, defined one. Then,

DataGrid.TableStyle[index].GridColumnStyle[index].Width=100

"Prateek" <hi@amy.com> wrote in message news:ut**************@tk2msftngp13.phx.gbl...
Hi,

How can I change the width of a column in datagrid control?

TIA
Prateek
Jul 21 '05 #5

P: n/a
Hi,

Each and every column of datagrid has "ItemStyle-Width"
property which defines the column width of the datagrid.
So you can set the width of the datagrid columns (Bound
Column, Template Column) by the following

<asp:BoundColumn ItemStyle-Width="10%"></asp:BoundColumn>
<asp:TemplateColumn ItemStyle-
Width="25%"></asp:TemplateColumn>

-----Original Message-----
It doesn't work. The line below does not compile:

MyGrid.Columns[index].ItemStyle.Width=100

And when I write:

MyGrid.Columns[index].ItemStyle.Width= Unit.Pixel(10) or new Unit(10)
This gives a run time error "Index out of range"

Please help!!
"Norman Yuan" <no********@RemoveThis.shaw.ca> wrote in message news:5AjLb.28257$ts4.932@pd7tw3no...Look into below object chain:

DataGrid-->Columns(DataGridColumn)-->ItemStyle (TableItemStyle)->Width
So,

MyGrid.Columns[index].ItemStyle.Width=100
"Prateek" <hi@amy.com> wrote in message news:eG**************@TK2MSFTNGP12.phx.gbl... Thanks for reply.
However, I am referring to the web form datagrid.
Please let me know.

Thanks for any help u can provide

"Norman Yuan" <no********@RemoveThis.shaw.ca> wrote in message news:7MgLb.26995$ts4.12086@pd7tw3no... Assume your are talking about Win form DataGrid.

If you haven't define a TableStyle in DataGrid, defined one. Then,
DataGrid.TableStyle[index].GridColumnStyle [index].Width=100
"Prateek" <hi@amy.com> wrote in message news:ut**************@tk2msftngp13.phx.gbl... Hi,

How can I change the width of a column in datagrid control?
TIA
Prateek

Jul 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.