473,545 Members | 2,001 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid col width

Hi,

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

TIA
Prateek
Jul 21 '05 #1
5 3361
Assume your are talking about Win form DataGrid.

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

DataGrid.TableS tyle[index].GridColumnStyl e[index].Width=100

"Prateek" <hi@amy.com> wrote in message news:ut******** ******@tk2msftn gp13.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********@Rem oveThis.shaw.ca > wrote in message news:7MgLb.2699 5$ts4.12086@pd7 tw3no...
Assume your are talking about Win form DataGrid.

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

DataGrid.TableS tyle[index].GridColumnStyl e[index].Width=100

"Prateek" <hi@amy.com> wrote in message news:ut******** ******@tk2msftn gp13.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(DataGr idColumn)-->ItemStyle(Tabl eItemStyle)->Width

So,

MyGrid.Columns[index].ItemStyle.Widt h=100
"Prateek" <hi@amy.com> wrote in message news:eG******** ******@TK2MSFTN GP12.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********@Rem oveThis.shaw.ca > wrote in message news:7MgLb.2699 5$ts4.12086@pd7 tw3no...
Assume your are talking about Win form DataGrid.

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

DataGrid.TableS tyle[index].GridColumnStyl e[index].Width=100

"Prateek" <hi@amy.com> wrote in message news:ut******** ******@tk2msftn gp13.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.Widt h=100

And when I write:

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

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

Please help!!
"Norman Yuan" <no********@Rem oveThis.shaw.ca > wrote in message news:5AjLb.2825 7$ts4.932@pd7tw 3no...
Look into below object chain:

DataGrid-->Columns(DataGr idColumn)-->ItemStyle(Tabl eItemStyle)->Width

So,

MyGrid.Columns[index].ItemStyle.Widt h=100
"Prateek" <hi@amy.com> wrote in message news:eG******** ******@TK2MSFTN GP12.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********@Rem oveThis.shaw.ca > wrote in message news:7MgLb.2699 5$ts4.12086@pd7 tw3no...
Assume your are talking about Win form DataGrid.

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

DataGrid.TableS tyle[index].GridColumnStyl e[index].Width=100

"Prateek" <hi@amy.com> wrote in message news:ut******** ******@tk2msftn gp13.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:BoundColum n ItemStyle-Width="10%"></asp:BoundColumn >
<asp:TemplateCo lumn ItemStyle-
Width="25%"></asp:TemplateCol umn>

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

MyGrid.Colum ns[index].ItemStyle.Widt h=100

And when I write:

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

Please help!!
"Norman Yuan" <no********@Rem oveThis.shaw.ca > wrote in message news:5AjLb.2825 7$ts4.932@pd7tw 3no...Look into below object chain:

DataGrid-->Columns(DataGr idColumn)-->ItemStyle (TableItemStyle )->Width
So,

MyGrid.Colum ns[index].ItemStyle.Widt h=100
"Prateek" <hi@amy.com> wrote in message news:eG******** ******@TK2MSFTN GP12.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********@Rem oveThis.shaw.ca > wrote in message news:7MgLb.2699 5$ts4.12086@pd7 tw3no... Assume your are talking about Win form DataGrid.

If you haven't define a TableStyle in DataGrid, defined one. Then,
DataGrid.TableS tyle[index].GridColumnStyl e [index].Width=100
"Prateek" <hi@amy.com> wrote in message news:ut******** ******@tk2msftn gp13.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
7668
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 Impact Summary</td> </tr> <tr> <td colspan=2></td>
2
2489
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 the OID of Person), the information of the person matching the selected OID is shown in the Textboxes (Name, Address, id, etc) and the courses this...
5
2080
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
6380
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
1818
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 with a buttonRow that does a delete function for me. Microsoft support helped me back then to get this done. Here is part of the code that creates...
6
2737
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 freeze.
5
553
by: Prateek | last post by:
Hi, How can I change the width of a column in datagrid control? TIA Prateek
10
2941
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 22222 D E F 33333 G H I 44444 J K L
2
6567
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 in the child datagrid and then go to the combobox and choose another vendor. When the new vendor is loaded nothing shows in the datagrid but the...
0
7479
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7669
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7439
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7773
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5987
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5343
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4962
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3468
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
722
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.