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

Repost: DataGrid column width bug

I have googled for this issue, and many other people have the same problem
with no resolution. The data grid column sizes automatically resize based
on their contents no matter what the Style.Width is set to. I was looking
at the HTML output, and the values I entered for Width does not even get
generated.

And to make things worse, even though I set the width of the Grid to 100%,
it actually expands beyond the edge of the screen forcing the user to scroll
horizontally. Here is my code:

Private Sub AddTemplateColumn( _
ByVal InsertAt As Integer, _
ByVal itemTemplate As ITemplate, _
ByVal headerText As String, _
ByVal pixelWidth As Integer)

Dim tempColumn As New TemplateColumn

dgOptions.Columns.AddAt(InsertAt, tempColumn)

With tempColumn
.ItemTemplate = itemTemplate
.HeaderText = headerText
.ItemStyle.Width = _
New Web.UI.WebControls.Unit( _
pixelWidth, _
UnitType.Pixel)
End With
End Sub

This is driving me insane.

Thanks,
Jeremy
Nov 18 '05 #1
3 999
Hello Jeremy,

I responded to your previous post about this. Did that solution not work out for you?

"I think you will need to set the width of the column on the datagrid itself:

ie: dgOptions.Columns.Item(InsertAt).Width = new Web.UI.WebControls.unit(pixelWidth, UnitType.Pixel)"

--
Matt Berther
http://www.mattberther.com
Nov 18 '05 #2
Datagrids generate HTML tables, which are notorious for doing whatever they
want, no matter how hard you beat them.
Try putting <div> controls with the parameters you want inside the cells.
You may have to do this by editing the templates in HTML mode to get the
results you want.

"Matt Berther" <mb******@hotmail.com> wrote in message
news:uQ**************@TK2MSFTNGP12.phx.gbl...
Hello Jeremy,

I responded to your previous post about this. Did that solution not work out for you?
"I think you will need to set the width of the column on the datagrid itself:
ie: dgOptions.Columns.Item(InsertAt).Width = new Web.UI.WebControls.unit(pixelWidth, UnitType.Pixel)"
--
Matt Berther
http://www.mattberther.com

Nov 18 '05 #3
Hello Rick,
Datagrids generate HTML tables, which are notorious for doing whatever
they
want, no matter how hard you beat them.
Try putting <div> controls with the parameters you want inside the
cells.
You may have to do this by editing the templates in HTML mode to get
the
results you want.


Yes, I fought this for quite some time when trying to create a datagrid where the header stays in place while the content scrolls. However, I did get around this using the code example I sent to Jeremy.

--
Matt Berther
http://www.mattberther.com
Nov 18 '05 #4

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

Similar topics

5
by: Prateek | last post by:
Hi, How can I change the width of a column in datagrid control? TIA Prateek
9
by: web1110 | last post by:
Hi y'all, I have resized the columns in a DataGrid and I want to set the width of the DataGrid to fit the columns. Just summing the column widths is too short due to the grid and gray row...
3
by: Richard | last post by:
I have a requirement to put a GDI style circle or rectangle border around the selected row of a datagrid/ It will overlap into the row above and below the selected row. Doing this in a the OnPaint...
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.
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...
2
by: Lincoln Yeoh | last post by:
Sorry for the repost. Just wondering if anyone has a workaround for 7.4? At 11:25 AM 1/27/2004 -0500, Tom Lane wrote: >Martijn van Oosterhout <kleptog@svana.org> writes: > > I'm afraid I'll have...
2
by: Charleees | last post by:
Hi all, I have a DataGrid with Template Columns..... There are LAbels,Linkbuttons in the Single Row.. I have to set the Constant Column width for those Template Columns in Grid... Wat...
2
by: cj | last post by:
I was looking over some of my 2003 code today (see below) that loads a foxpro table via oledb connection. I used a sub "autosizecolumns" I found on the web but I never quite understood why they...
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.