Datagrid col width

N

Norman Yuan

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

Hi,

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

TIA
Prateek
 
P

Prateek

Thanks for reply.
However, I am referring to the web form datagrid.
Please let me know.

Thanks for any help u can provide

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

Hi,

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

TIA
Prateek
 
N

Norman Yuan

Look into below object chain:

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

So,

MyGrid.Columns[index].ItemStyle.Width=100
Thanks for reply.
However, I am referring to the web form datagrid.
Please let me know.

Thanks for any help u can provide

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

Hi,

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

TIA
Prateek
 
P

Prateek

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!!


Look into below object chain:

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

So,

MyGrid.Columns[index].ItemStyle.Width=100
Thanks for reply.
However, I am referring to the web form datagrid.
Please let me know.

Thanks for any help u can provide

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

Hi,

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

TIA
Prateek
 
S

Sundar

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-
-----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" <[email protected]> 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
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" <[email protected]> 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

Hi,

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

TIA
Prateek
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top