473,321 Members | 1,916 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,321 software developers and data experts.

Freezing Datagrid Column Headers

Hi,
We have a datagrid with column headers. If the datagrid has more than say
25 rows the user needs to scroll down to be able to see the rest of the grid.
When the user does this the column headers scrolls up off the screen and it
becomes hard for the user to determine what the columns are. Is there a way
to keep the columns headers in place (only for vertical scrolling) when the
user scrolls down.

Thanks,
John

Jan 18 '06 #1
2 1968
First, wrap your DataGrid in a <div>, and set the div's "overflow"
style to "scroll". This way, the user won't have to scroll the entire
page to view the contents of the grid (and this is also necessary for
the following part to work right).

Then give the DataGrid's header the following styles:

position: relative;
top: expression(this.offsetParent.scrollTop - 2);

You might have to play around with border width, padding, etc. to get
it to look right, but this should do you what you want. Hope it helps.

Luke

Jan 18 '06 #2
Luke,
Thanks I'll give it a try!

"slagomite" wrote:
First, wrap your DataGrid in a <div>, and set the div's "overflow"
style to "scroll". This way, the user won't have to scroll the entire
page to view the contents of the grid (and this is also necessary for
the following part to work right).

Then give the DataGrid's header the following styles:

position: relative;
top: expression(this.offsetParent.scrollTop - 2);

You might have to play around with border width, padding, etc. to get
it to look right, but this should do you what you want. Hope it helps.

Luke

Jan 18 '06 #3

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

Similar topics

8
by: DraguVaso | last post by:
Hi, I want to override the MyBase.OnPaint(ByVal pe As System.Windows.Forms.PaintEventArgs) of the DataGrid, to have some custom property's designed (other column headers etc). The problem is...
4
by: Randy | last post by:
I have a DataTable in a DataGrid. If I click on the DataGrid, HitTestInfo in dataGrid1_MouseDown returns a Row and Column number. I can use the Row number to say: DataRow dr = dataTable.Rows;...
1
by: ElenaR | last post by:
I need to figure out how to name my column headers in a DataGrid. In VB6, I could write DataGrid1.Columns(0).Caption = "ID". What is the format for VB.NET? Thanks in Advance!
4
by: skOOb33 | last post by:
I successfully autosized the columns and rows on my Datagrid, and am now facing another issue. Having the sorting ability by clicking the column headers is key, but when I do that, it resizes all...
2
by: Job Lot | last post by:
Is there any way of freezing columns in Windows Forms Data Grid control? Thanks
4
by: Jeff | last post by:
I am stuck on trying to generate two columns headers for a datagrid on form load. I can use a datatable as the datasource and get the results I want, but I want to set different column widths and...
0
by: nkparimi | last post by:
Hi, Here's what I'm trying: given an html table, to freeze the column headers and/or left column in IE. I understand that this is possible thru style sheets in IE, as suggested in the following:...
4
by: cooltech77 | last post by:
Hi, I am trying to build the following functionality in the datagrid. I have a lot of columns in the datagrid which are being populated from the database and the user needs to scroll...
0
by: rn5a | last post by:
A DataGrid control displays records from a SQL Server 2005 DB table. The AllowSorting property of the DataGrid has been set to True & the SortExpressions of the BoundColumns have been set to the...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
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.