473,407 Members | 2,314 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,407 software developers and data experts.

Datagrid col width

Hi,

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

TIA
Prateek
Jul 21 '05 #1
5 3350
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Billy Jacobs | last post by:
I am using a datagrid to display some data. I need to create 2 header rows for this grid with columns of varying spans. In html it would be the following. <Table> <tr> <td colspan=8>Official...
2
by: Josef Meile | last post by:
Hi, I'm using a ComboBox, some Textboxes, and a DataGrid to represent a many-to-many relationship between Person and Course. Each time that I change the value in the ComboBox (which for now is...
5
by: John M | last post by:
Hello, In Visual Studio .NET 2003, How can I change the columns' width (at design or runtime) of datagrid ? Thanks :)
2
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
4
by: Steve | last post by:
I am fairly new to VB.NET, and I am rewriting an application I wrote a while back, also in VB.NET. I aplied some new things I learned. Anyway, here is my problem....... I have a custom DataGrid...
6
by: Agnes | last post by:
I understand it is impossible, but still curious to know "Can I freeze several column in the datagrid, the user can only scroll the first 3 columns (not verical), for the rest of the coulumn, it is...
5
by: Prateek | last post by:
Hi, How can I change the width of a column in datagrid control? TIA Prateek
10
by: amiga500 | last post by:
Hello, I have one basic simple question. When I have multiple records in the datagrid as follows: Code Product 1 Product 2 Product 3 11111 A B C...
2
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
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,...

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.