473,395 Members | 1,568 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,395 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 3348
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: 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
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?
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.