473,503 Members | 6,385 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

the column size of gridview

hi all:

the one of the column of gridview got multiple line data to be shown , so
how do i deal with it? what i am thinking about is using template field
instead of the boundfield. is that other solution out there?

Cheers

Nick
Sep 22 '06 #1
1 2406
Hi Nick,

You can solve this problem with the DataGridView.AutoSizeColumns() method,
with one of the values from the DataGridViewAutoSizeColumnCriteria
enumeration.
You can choose to size columns based on the width of header text, the
currently displayed rows, or all the rows in the table.

The following code snippet resize columns based on the width of the largest
piece of text in a header or one of the rows for this column.
DataGridView1.AutoSizeColumns( _
DataGridViewAutoSizeColumnCriteria.HeaderAndRows)

Please note that this method needs to be invoked after you bind the data or
it won't have any effect. You might also want to use it after user editing
(perhaps in response to an event like DataGridView.CellValueChanged).

Rather than widening columns to fit, you can change the row size. By
default, the text in a column will wrap over multiple lines.

If you use the DataGridView.AutoSizeRows() method, the row will be
heightened to fit the content.

Before you use this method, you might want to widen the column size,
particularly if you have a field that contains a large amount of text. For
example, the following code snippet quadruples the size of the Description
column, and then resizes
the rows to accommodate the content.

DataGridView.Columns("Description").Width *= 4
DataGridView.AutoSizeRows( _
DataGridViewAutoSizeRowsMode.HeaderAndColumnsAllRo ws)

Pls let me know whether this helps you
Thanks & Regards,
Sundar Narasimman

"Nick" wrote:
hi all:

the one of the column of gridview got multiple line data to be shown , so
how do i deal with it? what i am thinking about is using template field
instead of the boundfield. is that other solution out there?

Cheers

Nick
Sep 22 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3531
by: Eric | last post by:
I have a GridView control that I want to sort on multiple columns when I click a particular column. For example, I display Last name + ", " + First name in the first column and display id in the...
1
5913
by: msch-prv | last post by:
I have difficulties adjusting the column width of a gridview control. The column width changes appear in the design grid, but at run-time the width changes back to what I presume are the grid's...
1
4343
by: JB | last post by:
I'm dynamically creating a Gridview object and filling it with contents from an ArrayList as follows: GridView2.AutoGenerateColumns = true; GridView2.DataSource = ArrayListObject;...
3
3857
by: jobs | last post by:
I have a gridview on another page with a column that will link to this page. I'm flirting with design options, but am considering a template field with hyperlink navigateurl that includes a query...
5
3983
by: bbawa1 | last post by:
I have a GetData methd which is returning a table using
1
1576
by: ckerns | last post by:
Is there a way to format the column size of a Grid view control?
2
3097
by: Kbalz | last post by:
I have a user control that has a gridview in it. I am dynamically setting up its datasource and columns based on an XML file. I have everything done except adding columns to the gridview, so that...
1
2380
by: Ben | last post by:
Hi, I'm designing a c# page and trying to add a checkbox column to a GridView, I've added a Template Row (as described at: http://aspnet.4guysfromrolla.com/articles/052406-1.aspx) and in the...
0
1403
by: progman417 | last post by:
I have a gridview with a dropdown list in an EditItemTemplate. I haven't set a width for the columns, so that they dynamically size according to the data displayed. When it goes into edit...
0
7194
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
7267
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
7316
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
7449
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...
1
4993
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...
0
3160
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...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
729
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
372
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...

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.