views:

613

answers:

3

Let's say I have data structures that're something like this:

Public Class AttendenceRecord
  Public CourseDate As Date
  Public StudentsInAttendence As Integer
End Class

Public Class Course
  Public Name As String
  Public CourseID As String
  Public Attendance As List(Of AttendenceRecord)
End Class

And I want a table that looks something like this:

| Course Name | Course ID | [Attendence(0).CourseDate] | [Attendence(1).CourseDate]| ...
| Intro to CS |  CS-1000  |             23             |              24           | ...
| Data Struct |  CS-2103  |             15             |              14           | ...

How would I, in the general case, get everything to the right of Course ID to be horizontally scrollable, while holding Course Name and Course ID in place? Ideally using a table, listview, or datagrid inside ASP.NET and/or WinForms.

+1  A: 

In pure .Net I don't know of anything. There are CSS Solutions for a fixed header. But a fixed left column, in my experience, requires some javascript finangling.

Took me a minute to find the old example. Host has since gone down. http://web.archive.org/web/20080215013647/http://www.litotes.demon.co.uk/example_scripts/tableScroll.html

This is the mechanism I used to get it to work: Take a normal table, and separate it out into 4 other tables. Get the column widths and row heights to match up using business constraints, and then link the onscroll event to scroll the other tables.

Tom Ritter
A: 

Here's an example using just HTML and CSS to achieve what I think you're looking for:

http://www.shrutigupta.com/index.php/2005/12/12/how-to-create-table-with-first-column-frozen/

Brian Sullivan
It does achieve the intended effect.I suppose I should've asked for a more generic answer. It looks like, in this case you need to either use static CSS for static data, or generate that on the fly. I'm really concerned about the general case, even if I only have a specific case right now.
Sam Erwin
The site you link is flagged as malware container site by Google Chrome
Eduardo Molteni
Firefox also flags it. And apparently the PHP seems broken (opened in Lynx)
toast
+1  A: 

You can get this functionality from the System.Windows.Forms.DataGridView control. When you create columns you can set them to be frozen which will then only scroll those columns to the right of the frozen column(s).

akmad
Any ASP.NET equivalents? Just wondering, as it looks like this would be the answer in WinForms.
Sam Erwin
Not sure of any ASP.Net controls that do this, but I don't know ASP.Net very well so there very well may be something to do this.
akmad