要求功能,最好和VB的vs-flexGrid控件有同等的功能,但是最起碼要有:
1、橫滾動條
2、竪滾動條,可以自定義只滾動哪些列

解决方案 »

  1.   

    http://community.csdn.net/Expert/topic/3633/3633602.xml?temp=.1314203
      

  2.   

    WebGrid for .net控件: http://www.evget.com/view/viewProductInfo.asp?productId=89 , 这就是最好的!!
    功能非常强大, 能实现在线数据输入,修改,删除(后台提交,不用刷新页面!!), 列拖动, 排序,分组, 主从表显示, 导出数据到excel, 右键菜单快捷操作, 列统计(实现总计功能)..............并且所有的这些操作都不需要刷新页面, 能让你对Web控件能有一个全新的认识
      

  3.   

    不好意思,我刚做了一个
    就是你要功能,给你,不过用法,你就记住三个属性
    FixedColumns:你要滚动横向,从哪一列开始ShowScrollMode:你要横向滚动,还是竖项滚动ScrollBarWidth:滚动条的宽度记住,你先设置ShowScrollMode,然后ScrollBarWidth的宽度,你可能设置FixedColumns的时候回发现前面的几列不见了,由于你没有给前面几列没设置宽度所以你在添加列的时候还要给没一列加一个宽度,会的吧,属性编辑器中加
      

  4.   

    Imports System.ComponentModel
    Imports System.Web.UI
    Imports System.Drawing
    Imports System.Web
    Imports System.Web.UI.WebControls<DefaultProperty("Text"), ToolboxData("<{0}:XYScrollDataGrid runat=server></{0}:XYScrollDataGrid>")> _
    Public Class XYScrollDataGrid
        Inherits System.Web.UI.WebControls.DataGrid    Private mScrollWidth As Unit
        Private mDataMode As DataModeType
        Private mFixedColumns As Integer
        Private mShowScrollDataMode As ShowScrollDataMode
        Public Enum ShowScrollDataMode
            XScroll
            YScroll
            None
        End Enum    Public Enum DataModeType
            可変行Scroll
            固定行Scroll
        End Enum#Region "プロパティ"
    #Region "親クラスから継承された表示プロパティ"    <NotifyParentProperty(True), Browsable(False), _
        EditorBrowsable(EditorBrowsableState.Advanced)> _
        Public Overrides Property AutoGenerateColumns() As Boolean
            Get
                Return MyBase.AutoGenerateColumns
            End Get
            Set(ByVal Value As Boolean)
                MyBase.AutoGenerateColumns = False
            End Set
        End Property    <NotifyParentProperty(True), Browsable(False), _
        EditorBrowsable(EditorBrowsableState.Advanced)> _
        Public Shadows Property DataMember() As String
            Get
                Return MyBase.DataMember
            End Get
            Set(ByVal Value As String)
                MyBase.DataMember = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
         Public Overrides Property AllowCustomPaging() As Boolean
            Get
                Return MyBase.AllowCustomPaging
            End Get
            Set(ByVal Value As Boolean)
                MyBase.AllowCustomPaging = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property AllowPaging() As Boolean
            Get
                Return MyBase.AllowPaging
            End Get
            Set(ByVal Value As Boolean)
                MyBase.AllowPaging = Value
            End Set
        End Property    <NotifyParentProperty(True), _
        Browsable(False), EditorBrowsable(EditorBrowsableState.Advanced)> _
        Public Overrides Property AllowSorting() As Boolean
            Get
                Return MyBase.AllowSorting
            End Get
            Set(ByVal Value As Boolean)
                MyBase.AllowSorting = Value
            End Set
        End Property
      

  5.   

    <NotifyParentProperty(True)> _
        Public Overrides ReadOnly Property AlternatingItemStyle() As TableItemStyle
            Get
                Return MyBase.AlternatingItemStyle
            End Get
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property BackColor() As Color
            Get
                Return MyBase.BackColor
            End Get
            Set(ByVal Value As Color)
                MyBase.BackColor = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
            Public Overrides Property BackImageUrl() As String
            Get
                Return MyBase.BackImageUrl
            End Get
            Set(ByVal Value As String)
                MyBase.BackImageUrl = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property BorderColor() As Color
            Get
                Return MyBase.BorderColor
            End Get
            Set(ByVal Value As Color)
                MyBase.BorderColor = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property BorderStyle() As BorderStyle
            Get
                Return MyBase.BorderStyle
            End Get
            Set(ByVal Value As BorderStyle)
                MyBase.BorderStyle = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property BorderWidth() As Unit
            Get
                Return MyBase.BorderWidth
            End Get
            Set(ByVal Value As Unit)
                MyBase.BorderWidth = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
           Public Overrides Property CellPadding() As Integer
            Get
                Return MyBase.CellPadding
            End Get
            Set(ByVal Value As Integer)
                MyBase.CellPadding = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property CellSpacing() As Integer
            Get
                Return MyBase.CellSpacing
            End Get
            Set(ByVal Value As Integer)
                MyBase.CellSpacing = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides ReadOnly Property Columns() As DataGridColumnCollection
            Get
                Return MyBase.Columns
            End Get
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property EditItemIndex() As Integer
            Get
                Return MyBase.EditItemIndex
            End Get
            Set(ByVal Value As Integer)
                MyBase.EditItemIndex = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides ReadOnly Property EditItemStyle() As TableItemStyle
            Get
                Return MyBase.EditItemStyle
            End Get
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property Enabled() As Boolean
            Get
                Return MyBase.Enabled
            End Get
            Set(ByVal Value As Boolean)
                MyBase.Enabled = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides ReadOnly Property FooterStyle() As TableItemStyle
            Get
                Return MyBase.FooterStyle
            End Get
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property ForeColor() As Color
            Get
                Return MyBase.ForeColor
            End Get
            Set(ByVal Value As Color)
                MyBase.ForeColor = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property GridLines() As GridLines
            Get
                Return MyBase.GridLines
            End Get
            Set(ByVal Value As GridLines)
                MyBase.GridLines = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides ReadOnly Property HeaderStyle() As TableItemStyle
            Get
                Return MyBase.HeaderStyle
            End Get
        End Property
      

  6.   

    <NotifyParentProperty(True)> _
        Public Overrides Property Height() As Unit
            Get
                Return MyBase.Height
            End Get
            Set(ByVal Value As Unit)
                MyBase.Height = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property HorizontalAlign() As HorizontalAlign
            Get
                Return MyBase.HorizontalAlign
            End Get
            Set(ByVal Value As HorizontalAlign)
                MyBase.HorizontalAlign = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides ReadOnly Property ItemStyle() As TableItemStyle
            Get
                Return MyBase.ItemStyle
            End Get
        End Property    <NotifyParentProperty(True)> _
        Public Overrides ReadOnly Property PagerStyle() As DataGridPagerStyle
            Get
                Return MyBase.PagerStyle
            End Get
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property PageSize() As Integer
            Get
                Return MyBase.PageSize
            End Get
            Set(ByVal Value As Integer)
                MyBase.PageSize = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
           Public Overrides Property ShowFooter() As Boolean
            Get
                Return MyBase.ShowFooter
            End Get
            Set(ByVal Value As Boolean)
                MyBase.ShowFooter = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
               Public Overrides Property ShowHeader() As Boolean
            Get
                Return MyBase.ShowHeader
            End Get
            Set(ByVal Value As Boolean)
                MyBase.ShowHeader = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property Visible() As Boolean
            Get
                Return MyBase.Visible
            End Get
            Set(ByVal Value As Boolean)
                MyBase.Visible = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property Width() As Unit
            Get
                Return MyBase.Width
            End Get
            Set(ByVal Value As Unit)
                MyBase.Width = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
           Public Overrides Property CssClass() As String
            Get
                Return MyBase.CssClass
            End Get
            Set(ByVal Value As String)
                MyBase.CssClass = Value
            End Set
        End Property
    #End Region    <Category("モード選択"), DefaultValue(GetType(Unit), "0px"), _
           Description("スクロールの幅")> _
        Public Property ScrollBarWidth() As Unit
            Get
                '設定値を戻す
                Return mScrollWidth
            End Get        Set(ByVal Value As Unit)
                '設定値
                mScrollWidth = Value
            End Set
        End Property    <Category("モード選択"), DefaultValue(0), _
           Description("固定行の個数")> _
           Public Property FixedColumns() As Integer
            Get
                If mShowScrollDataMode = ShowScrollDataMode.XScroll Then
                    Return mFixedColumns
                End If
            End Get        Set(ByVal Value As Integer)
                If mShowScrollDataMode = ShowScrollDataMode.XScroll Then
                    If Me.Columns.Count < Value And Not Me.Columns.Count = 0 Then
                        mFixedColumns = Me.Columns.Count
                    ElseIf Value < 0 Then
                        mFixedColumns = 0
                    Else
                        mFixedColumns = Value
                    End If
                End If
            End Set
        End Property    <Category("モード選択"), DefaultValue(GetType(ShowScrollDataMode), "XScroll"), _
         Description("XScroll")> _
            Public Property ShowScrollMode() As ShowScrollDataMode
            Get
                Return mShowScrollDataMode
            End Get
            Set(ByVal Value As ShowScrollDataMode)
                mShowScrollDataMode = Value
            End Set
        End Property
    #End Region    Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
            Dim tmpArrayList As Hashtable        tmpArrayList = New Hashtable
            tmpArrayList.Add("Z-INDEX", Style.Item("Z-INDEX"))
            tmpArrayList.Add("LEFT", Style.Item("LEFT"))
            tmpArrayList.Add("POSITION", Style.Item("POSITION"))
            tmpArrayList.Add("TOP", Style.Item("TOP"))        Me.Style.Remove("Z-INDEX")
            Me.Style.Remove("LEFT")
            Me.Style.Remove("POSITION")
            Me.Style.Remove("TOP")        writer.Write("<div" & " id='" & Me.ID & "_All' style='")
            writer.Write("Z-INDEX: " & tmpArrayList("Z-INDEX") & ";")
            writer.Write("LEFT: " & tmpArrayList("LEFT") & ";")
            writer.Write("POSITION: " & tmpArrayList("POSITION") & ";")
            writer.Write("TOP: " & tmpArrayList("TOP") & "' ms_positioning = 'FlowLayout'>")        FixedColumnDataGrid(writer)
            writer.Write("</div>")
        End Sub
      

  7.   

    Private Sub FixedColumnDataGrid(ByVal output As System.Web.UI.HtmlTextWriter)
            Dim divStyle As String
            Dim widthOne As String
            Dim widthTwo As String
            Dim heightOne As String
            Dim heightTwo As String
            Dim visiableColumn() As Boolean
            Dim k As Integer        ReDim visiableColumn(Me.Columns.Count - 1)        For i As Integer = 0 To Me.Columns.Count - 1
                visiableColumn(i) = Me.Columns(i).Visible
            Next        k = 0        For i As Integer = 0 To mFixedColumns - 1            For j As Integer = k To Me.Columns.Count - 1                If Me.Columns.Item(j).Visible Then                    widthOne = CStr((Val(widthOne) + Val(Me.Columns(j).HeaderStyle.Width.ToString)))
                        k = j + 1                    Exit For
                    End If
                Next
            Next
            widthOne = CType(Val(widthOne) + 1 + Val(CellSpacing) * mFixedColumns, String)
            If mFixedColumns = 0 Then
                widthOne = "0"
            End If
            widthTwo = mScrollWidth.ToString
            heightTwo = mScrollWidth.ToString
            OutPutLayout(widthOne, widthTwo, heightOne, heightTwo, visiableColumn, output)
        End Sub    Private Sub OutPutLayout(ByVal widthOne As String, ByVal widthTwo As String, _
        ByVal heightOne As String, ByVal heightTwo As String, _
        ByVal visiableColumn As Boolean(), _
        ByVal output As System.Web.UI.HtmlTextWriter)
            output.Write("<table cellSpacing='0' cellPadding='0' border='0'>")
            If ShowScrollMode = ShowScrollDataMode.None Then
                output.Write("<tr>")
                If Not Me.Columns.Count <= mFixedColumns Then
                    Call ShowLeft("", output)
                End If            output.Write("</tr>")
            ElseIf ShowScrollMode = ShowScrollDataMode.XScroll Then
                output.Write("<tr>")
                Call ShowLeft(widthOne, output)
                If Not Me.Columns.Count <= mFixedColumns Then
                    Call ShowRight(widthTwo, output)
                End If
                output.Write("</tr>")
            ElseIf ShowScrollMode = ShowScrollDataMode.YScroll Then
                '縦スクロールモードの場合
                output.Write("<tr>")
                ShowTop(heightOne, output)
                output.Write("</tr>")
                If Not Me.Columns.Count <= mFixedColumns Then
                    output.Write("<tr>")
                    Call ShowBottom(heightTwo, output)
                    output.Write("</tr>")
                End If
            End If
            For i As Integer = 0 To Me.Columns.Count - 1
                Me.Columns.Item(i).Visible = visiableColumn(i)
            Next
            output.Write("</table>")
        End Sub    Private Sub ShowLeft(ByVal width As String, ByVal output As System.Web.UI.HtmlTextWriter)
            Dim divStyle As String
            output.Write("<td valign='top'>")
            divStyle = "<DIV id='" & Me.ID & "_DivLeft' style='OVERFLOW-X: hidden; WIDTH: " & _
                                width & ";" _
                                & " BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; " & _
                                "' ms_positioning = 'GridLayout' > "
            output.Write(divStyle)        If Me.mShowScrollDataMode = ShowScrollDataMode.None Then
                For i As Integer = 0 To Me.Items.Count - 1
                    Me.Items(i).Attributes("id") = Me.ID & "TRD" & i
                Next        Else
                For i As Integer = 0 To Me.Items.Count - 1
                    Me.Items(i).Attributes("id") = Me.ID & "TRL" & i
                Next
            End If
            Me.Style("BORDER-STYLE") = "none"
            MyBase.Render(output)
            output.Write("</DIV>")
            output.Write("</td>")
        End Sub    Private Sub ShowRight(ByVal width As String, ByVal output As System.Web.UI.HtmlTextWriter)
            Dim divStyle As String        output.Write("<td valign='top'>")
            divStyle = "<DIV id='" & Me.ID & "_DivRight' style='OVERFLOW-X: scroll; WIDTH: " & _
                                width & ";" & _
                    " BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; " & _
                                "' ms_positioning = 'GridLayout' > "
            output.Write(divStyle)
            If Not ShowScrollMode = ShowScrollDataMode.None Then
                For i As Integer = 0 To mFixedColumns - 1
                    For j As Integer = 0 To Me.Columns.Count - 1
                        If Me.Columns.Item(j).Visible Then
                            Me.Columns.Item(j).Visible = False
                            Exit For
                        End If
                    Next
                Next
            End If
            For i As Integer = 0 To Me.Items.Count - 1
                Me.Items(i).Attributes("id") = Me.ID & "TRR" & i
            Next
            Me.Style("BORDER-STYLE") = "none"
            MyBase.Render(output)
            output.Write("</DIV>")
            output.Write("</td>")
        End Sub    Private Sub ShowTop(ByVal height As String, ByVal output As System.Web.UI.HtmlTextWriter)        Dim divStyle As String        output.Write("<td valign='bottom'>")        divStyle = "<DIV id='" & Me.ID & "_DivTop' style='BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; " & _
                                "' ms_positioning = 'GridLayout' > "
            output.Write(divStyle)        For i As Integer = 0 To Me.Items.Count - 1
                Me.Items(i).Visible = False
            Next
            For i As Integer = 0 To Me.Items.Count - 1
                Me.Items(i).Attributes("id") = Me.ID & "TRD" & i
            Next
            Me.Style("BORDER-STYLE") = "none"
            Me.ShowFooter = False
            MyBase.Render(output)
            output.Write("</DIV>")
            output.Write("</td>")
        End Sub    Private Sub ShowBottom(ByVal height As String, ByVal output As System.Web.UI.HtmlTextWriter)        Dim divStyle As String        output.Write("<td valign='top'>")        divStyle = "<DIV id='" & Me.ID & "_DivBottom' style='OVERFLOW-Y: scroll; HEIGHT: " & _
                                height & ";" & _
                    " BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; " & _
                                "' ms_positioning = 'GridLayout' > "
            output.Write(divStyle)        For i As Integer = 0 To Me.Items.Count - 1
                Me.Items(i).Visible = True
            Next        For i As Integer = 0 To Me.Items.Count - 1
                Me.Items(i).Attributes("id") = Me.ID & "TRD" & i
            Next        Me.Style("BORDER-STYLE") = "none"
            Me.ShowHeader = False
            MyBase.Render(output)
            Me.ShowHeader = True        output.Write("</DIV>")
            output.Write("</td>")
        End Sub
    End Class
      

  8.   

    谢谢 rickjelly2004(rick & jelly) ( ) ,我这就试试
      

  9.   

    rickjelly2004(rick & jelly) 我用了你给的自定义控件,很好,但是我想要横竖都可以滚动的,如何改才能实现?
      

  10.   

    rickjelly2004(rick & jelly) 还有,如果设置横滚动条的时候,不是从第一列开始,那么,我把分页功能打开后,会出现2个分页的菜单,使我无法利用分页的菜单来实现双菜单的功能了,如何解决?
      

  11.   

    Imports System.ComponentModel
    Imports System.Web.UI
    Imports System.Drawing
    Imports System.Web
    Imports System.Web.UI.WebControls<DefaultProperty("Text"), ToolboxData("<{0}:XYScrollDataGrid runat=server></{0}:XYScrollDataGrid>")> _
    Public Class XYScrollDataGrid
        Inherits System.Web.UI.WebControls.DataGrid    Private mScrollWidth As Unit
        Private mDataMode As DataModeType
        Private mFixedColumns As Integer
        Private mShowScrollDataMode As ShowScrollDataMode
        Private ymScrollWidth As Unit    Public Enum ShowScrollDataMode
            XScroll
            YScroll
            Both
            None
        End Enum    Public Enum DataModeType
            可変行Scroll
            固定行Scroll
        End Enum#Region "プロパティ"
    #Region "親クラスから継承された表示プロパティ"    <NotifyParentProperty(True), Browsable(False), _
        EditorBrowsable(EditorBrowsableState.Advanced)> _
        Public Overrides Property AutoGenerateColumns() As Boolean
            Get
                Return MyBase.AutoGenerateColumns
            End Get
            Set(ByVal Value As Boolean)
                MyBase.AutoGenerateColumns = False
            End Set
        End Property    <NotifyParentProperty(True), Browsable(False), _
        EditorBrowsable(EditorBrowsableState.Advanced)> _
        Public Shadows Property DataMember() As String
            Get
                Return MyBase.DataMember
            End Get
            Set(ByVal Value As String)
                MyBase.DataMember = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
         Public Overrides Property AllowCustomPaging() As Boolean
            Get
                Return MyBase.AllowCustomPaging
            End Get
            Set(ByVal Value As Boolean)
                MyBase.AllowCustomPaging = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property AllowPaging() As Boolean
            Get
                Return MyBase.AllowPaging
            End Get
            Set(ByVal Value As Boolean)
                MyBase.AllowPaging = Value
            End Set
        End Property    <NotifyParentProperty(True), _
        Browsable(False), EditorBrowsable(EditorBrowsableState.Advanced)> _
        Public Overrides Property AllowSorting() As Boolean
            Get
                Return MyBase.AllowSorting
            End Get
            Set(ByVal Value As Boolean)
                MyBase.AllowSorting = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides ReadOnly Property AlternatingItemStyle() As TableItemStyle
            Get
                Return MyBase.AlternatingItemStyle
            End Get
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property BackColor() As Color
            Get
                Return MyBase.BackColor
            End Get
            Set(ByVal Value As Color)
                MyBase.BackColor = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
            Public Overrides Property BackImageUrl() As String
            Get
                Return MyBase.BackImageUrl
            End Get
            Set(ByVal Value As String)
                MyBase.BackImageUrl = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property BorderColor() As Color
            Get
                Return MyBase.BorderColor
            End Get
            Set(ByVal Value As Color)
                MyBase.BorderColor = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property BorderStyle() As BorderStyle
            Get
                Return MyBase.BorderStyle
            End Get
            Set(ByVal Value As BorderStyle)
                MyBase.BorderStyle = Value
            End Set
        End Property
      

  12.   

    <NotifyParentProperty(True)> _
        Public Overrides Property BorderWidth() As Unit
            Get
                Return MyBase.BorderWidth
            End Get
            Set(ByVal Value As Unit)
                MyBase.BorderWidth = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
           Public Overrides Property CellPadding() As Integer
            Get
                Return MyBase.CellPadding
            End Get
            Set(ByVal Value As Integer)
                MyBase.CellPadding = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property CellSpacing() As Integer
            Get
                Return MyBase.CellSpacing
            End Get
            Set(ByVal Value As Integer)
                MyBase.CellSpacing = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides ReadOnly Property Columns() As DataGridColumnCollection
            Get
                Return MyBase.Columns
            End Get
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property EditItemIndex() As Integer
            Get
                Return MyBase.EditItemIndex
            End Get
            Set(ByVal Value As Integer)
                MyBase.EditItemIndex = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides ReadOnly Property EditItemStyle() As TableItemStyle
            Get
                Return MyBase.EditItemStyle
            End Get
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property Enabled() As Boolean
            Get
                Return MyBase.Enabled
            End Get
            Set(ByVal Value As Boolean)
                MyBase.Enabled = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides ReadOnly Property FooterStyle() As TableItemStyle
            Get
                Return MyBase.FooterStyle
            End Get
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property ForeColor() As Color
            Get
                Return MyBase.ForeColor
            End Get
            Set(ByVal Value As Color)
                MyBase.ForeColor = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property GridLines() As GridLines
            Get
                Return MyBase.GridLines
            End Get
            Set(ByVal Value As GridLines)
                MyBase.GridLines = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides ReadOnly Property HeaderStyle() As TableItemStyle
            Get
                Return MyBase.HeaderStyle
            End Get
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property Height() As Unit
            Get
                Return MyBase.Height
            End Get
            Set(ByVal Value As Unit)
                MyBase.Height = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property HorizontalAlign() As HorizontalAlign
            Get
                Return MyBase.HorizontalAlign
            End Get
            Set(ByVal Value As HorizontalAlign)
                MyBase.HorizontalAlign = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides ReadOnly Property ItemStyle() As TableItemStyle
            Get
                Return MyBase.ItemStyle
            End Get
        End Property    <NotifyParentProperty(True)> _
        Public Overrides ReadOnly Property PagerStyle() As DataGridPagerStyle
            Get
                Return MyBase.PagerStyle
            End Get
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property PageSize() As Integer
            Get
                Return MyBase.PageSize
            End Get
            Set(ByVal Value As Integer)
                MyBase.PageSize = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
           Public Overrides Property ShowFooter() As Boolean
            Get
                Return MyBase.ShowFooter
            End Get
            Set(ByVal Value As Boolean)
                MyBase.ShowFooter = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
               Public Overrides Property ShowHeader() As Boolean
            Get
                Return MyBase.ShowHeader
            End Get
            Set(ByVal Value As Boolean)
                MyBase.ShowHeader = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property Visible() As Boolean
            Get
                Return MyBase.Visible
            End Get
            Set(ByVal Value As Boolean)
                MyBase.Visible = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
        Public Overrides Property Width() As Unit
            Get
                Return MyBase.Width
            End Get
            Set(ByVal Value As Unit)
                MyBase.Width = Value
            End Set
        End Property    <NotifyParentProperty(True)> _
           Public Overrides Property CssClass() As String
            Get
                Return MyBase.CssClass
            End Get
            Set(ByVal Value As String)
                MyBase.CssClass = Value
            End Set
        End Property
    #End Region
      

  13.   

    <Category("モード選択"), DefaultValue(GetType(Unit), "0px"), _
           Description("スクロールの幅")> _
        Public Property YScrollBarWidth() As Unit
            Get
                Return ymScrollWidth
            End Get        Set(ByVal Value As Unit)
                ymScrollWidth = Value
            End Set
        End Property    <Category("モード選択"), DefaultValue(GetType(Unit), "0px"), _
           Description("スクロールの幅")> _
        Public Property ScrollBarWidth() As Unit
            Get
                '設定値を戻す
                Return mScrollWidth
            End Get        Set(ByVal Value As Unit)
                '設定値
                mScrollWidth = Value
            End Set
        End Property    <Category("モード選択"), DefaultValue(0), _
           Description("固定行の個数")> _
           Public Property FixedColumns() As Integer
            Get
                If mShowScrollDataMode = ShowScrollDataMode.XScroll Then
                    Return mFixedColumns
                End If
            End Get        Set(ByVal Value As Integer)
                If mShowScrollDataMode = ShowScrollDataMode.XScroll Then
                    If Me.Columns.Count < Value And Not Me.Columns.Count = 0 Then
                        mFixedColumns = Me.Columns.Count
                    ElseIf Value < 0 Then
                        mFixedColumns = 0
                    Else
                        mFixedColumns = Value
                    End If
                End If
            End Set
        End Property    <Category("モード選択"), DefaultValue(GetType(ShowScrollDataMode), "XScroll"), _
         Description("XScroll")> _
            Public Property ShowScrollMode() As ShowScrollDataMode
            Get
                Return mShowScrollDataMode
            End Get
            Set(ByVal Value As ShowScrollDataMode)
                mShowScrollDataMode = Value
            End Set
        End Property
    #End Region    Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
            Dim tmpArrayList As Hashtable        tmpArrayList = New Hashtable
            tmpArrayList.Add("Z-INDEX", Style.Item("Z-INDEX"))
            tmpArrayList.Add("LEFT", Style.Item("LEFT"))
            tmpArrayList.Add("POSITION", Style.Item("POSITION"))
            tmpArrayList.Add("TOP", Style.Item("TOP"))        Me.Style.Remove("Z-INDEX")
            Me.Style.Remove("LEFT")
            Me.Style.Remove("POSITION")
            Me.Style.Remove("TOP")        writer.Write("<div" & " id='" & Me.ID & "_All' style='")
            writer.Write("Z-INDEX: " & tmpArrayList("Z-INDEX") & ";")
            writer.Write("LEFT: " & tmpArrayList("LEFT") & ";")
            writer.Write("POSITION: " & tmpArrayList("POSITION") & ";")
            writer.Write("TOP: " & tmpArrayList("TOP") & "' ms_positioning = 'FlowLayout'>")        FixedColumnDataGrid(writer)
            writer.Write("</div>")
        End Sub    Private Sub FixedColumnDataGrid(ByVal output As System.Web.UI.HtmlTextWriter)
            Dim divStyle As String
            Dim widthOne As String
            Dim widthTwo As String
            Dim heightOne As String
            Dim heightTwo As String
            Dim visiableColumn() As Boolean
            Dim k As Integer        ReDim visiableColumn(Me.Columns.Count - 1)        For i As Integer = 0 To Me.Columns.Count - 1
                visiableColumn(i) = Me.Columns(i).Visible
            Next        k = 0        For i As Integer = 0 To mFixedColumns - 1            For j As Integer = k To Me.Columns.Count - 1                If Me.Columns.Item(j).Visible Then                    widthOne = CStr((Val(widthOne) + Val(Me.Columns(j).HeaderStyle.Width.ToString)))
                        k = j + 1                    Exit For
                    End If
                Next
            Next
            widthOne = CType(Val(widthOne) + 1 + Val(CellSpacing) * mFixedColumns, String)
            If mFixedColumns = 0 Then
                widthOne = "0"
            End If
            widthTwo = mScrollWidth.ToString
            heightTwo = mScrollWidth.ToString
            OutPutLayout(widthOne, widthTwo, heightOne, heightTwo, visiableColumn, output)
        End Sub
      

  14.   

    Private Sub OutPutLayout(ByVal widthOne As String, ByVal widthTwo As String, _
        ByVal heightOne As String, ByVal heightTwo As String, _
        ByVal visiableColumn As Boolean(), _
        ByVal output As System.Web.UI.HtmlTextWriter)
            output.Write("<table cellSpacing='0' cellPadding='0' border='0'>")
            If ShowScrollMode = ShowScrollDataMode.None Then
                output.Write("<tr>")
                If Not Me.Columns.Count <= mFixedColumns Then
                    Call ShowLeft("", output)
                End If            output.Write("</tr>")
            ElseIf ShowScrollMode = ShowScrollDataMode.XScroll Then
                output.Write("<tr>")
                Call ShowLeft(widthOne, output)
                If Not Me.Columns.Count <= mFixedColumns Then
                    Call ShowRight(widthTwo, output)
                End If
                output.Write("</tr>")
            ElseIf ShowScrollMode = ShowScrollDataMode.YScroll Then
                output.Write("<tr>")
                ShowTop(heightOne, output)
                output.Write("</tr>")
                If Not Me.Columns.Count <= mFixedColumns Then
                    output.Write("<tr>")
                    Call ShowBottom(heightTwo, output)
                    output.Write("</tr>")
                End If
            ElseIf ShowScrollMode = ShowScrollDataMode.Both Then
                output.Write("<tr>")
                Call ShowLeft(widthOne, output)
                If Not Me.Columns.Count <= mFixedColumns Then
                    Call BothScroll(widthTwo, output)
                End If
                output.Write("</tr>")
            End If
            For i As Integer = 0 To Me.Columns.Count - 1
                Me.Columns.Item(i).Visible = visiableColumn(i)
            Next
            output.Write("</table>")
        End Sub    Private Sub BothScroll(ByVal width As String, ByVal output As System.Web.UI.HtmlTextWriter)
            Dim divStyle As String        output.Write("<td valign='top'>")
            divStyle = "<DIV id='" & Me.ID & "_DivRight' style='OVERFLOW: scroll; WIDTH: " & _
                                width & ";" & "HEIGHT: " & Me.YScrollBarWidth.ToString & ";" _
                    & " BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; " & _
                                "' ms_positioning = 'GridLayout' > "
            output.Write(divStyle)
            If Not ShowScrollMode = ShowScrollDataMode.None Then
                For i As Integer = 0 To mFixedColumns - 1
                    For j As Integer = 0 To Me.Columns.Count - 1
                        If Me.Columns.Item(j).Visible Then
                            Me.Columns.Item(j).Visible = False
                            Exit For
                        End If
                    Next
                Next
            End If
            For i As Integer = 0 To Me.Items.Count - 1
                Me.Items(i).Attributes("id") = Me.ID & "TRR" & i
            Next
            Me.Style("BORDER-STYLE") = "none"
            MyBase.Render(output)
            output.Write("</DIV>")
            output.Write("</td>")
        End Sub    Private Sub ShowLeft(ByVal width As String, ByVal output As System.Web.UI.HtmlTextWriter)
            Dim divStyle As String
            output.Write("<td valign='top'>")
            divStyle = "<DIV id='" & Me.ID & "_DivLeft' style='OVERFLOW-X: hidden; WIDTH: " & _
                                width & ";" _
                                & " BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; " & _
                                "' ms_positioning = 'GridLayout' > "
            output.Write(divStyle)        If Me.mShowScrollDataMode = ShowScrollDataMode.None Then
                For i As Integer = 0 To Me.Items.Count - 1
                    Me.Items(i).Attributes("id") = Me.ID & "TRD" & i
                Next        Else
                For i As Integer = 0 To Me.Items.Count - 1
                    Me.Items(i).Attributes("id") = Me.ID & "TRL" & i
                Next
            End If
            Me.Style("BORDER-STYLE") = "none"
            MyBase.Render(output)
            output.Write("</DIV>")
            output.Write("</td>")
        End Sub    Private Sub ShowRight(ByVal width As String, ByVal output As System.Web.UI.HtmlTextWriter)
            Dim divStyle As String        output.Write("<td valign='top'>")
            divStyle = "<DIV id='" & Me.ID & "_DivRight' style='OVERFLOW-X: scroll; WIDTH: " & _
                                width & ";" & _
                    " BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; " & _
                                "' ms_positioning = 'GridLayout' > "
            output.Write(divStyle)
            If Not ShowScrollMode = ShowScrollDataMode.None Then
                For i As Integer = 0 To mFixedColumns - 1
                    For j As Integer = 0 To Me.Columns.Count - 1
                        If Me.Columns.Item(j).Visible Then
                            Me.Columns.Item(j).Visible = False
                            Exit For
                        End If
                    Next
                Next
            End If
            For i As Integer = 0 To Me.Items.Count - 1
                Me.Items(i).Attributes("id") = Me.ID & "TRR" & i
            Next
            Me.Style("BORDER-STYLE") = "none"
            MyBase.Render(output)
            output.Write("</DIV>")
            output.Write("</td>")
        End Sub    Private Sub ShowTop(ByVal height As String, ByVal output As System.Web.UI.HtmlTextWriter)        Dim divStyle As String        output.Write("<td valign='bottom'>")        divStyle = "<DIV id='" & Me.ID & "_DivTop' style='BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; " & _
                                "' ms_positioning = 'GridLayout' > "
            output.Write(divStyle)        For i As Integer = 0 To Me.Items.Count - 1
                Me.Items(i).Visible = False
            Next
            For i As Integer = 0 To Me.Items.Count - 1
                Me.Items(i).Attributes("id") = Me.ID & "TRD" & i
            Next
            Me.Style("BORDER-STYLE") = "none"
            Me.ShowFooter = False
            MyBase.Render(output)
            output.Write("</DIV>")
            output.Write("</td>")
        End Sub    Private Sub ShowBottom(ByVal height As String, ByVal output As System.Web.UI.HtmlTextWriter)        Dim divStyle As String        output.Write("<td valign='top'>")        divStyle = "<DIV id='" & Me.ID & "_DivBottom' style='OVERFLOW-Y: scroll; HEIGHT: " & _
                                height & ";" & _
                    " BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; " & _
                                "' ms_positioning = 'GridLayout' > "
            output.Write(divStyle)        For i As Integer = 0 To Me.Items.Count - 1
                Me.Items(i).Visible = True
            Next        For i As Integer = 0 To Me.Items.Count - 1
                Me.Items(i).Attributes("id") = Me.ID & "TRD" & i
            Next        Me.Style("BORDER-STYLE") = "none"
            Me.ShowHeader = False
            MyBase.Render(output)
            Me.ShowHeader = True        output.Write("</DIV>")
            output.Write("</td>")
        End Sub
    End Class
      

  15.   

    哎呀,我不是说了吗?干嘛要横竖一起有呀
    那DATAGRID的PAGESIZE不是没用了不过你可以这样设置
    PAGESIZE设置大一点100,我的FIXCOLUMNS为0就行了
    这一个你提出来,我也只是为你,我改了一下。
      

  16.   

    麻烦了 rickjelly2004(rick & jelly)
      

  17.   

    把rickjelly2004(rick & jelly)的代码换成C#的那该多好啊~~~~~~~~~
      

  18.   

    using System.ComponentModel; 
    using System.Web.UI; 
    using System.Drawing; 
    using System.Web; 
    using System.Web.UI.WebControls; 
    [DefaultProperty("Text"), ToolboxData("<{0}:XYScrollDataGrid runat=server></{0}:XYScrollDataGrid>")] 
    public class XYScrollDataGrid : System.Web.UI.WebControls.DataGrid 

     private Unit mScrollWidth; 
     private DataModeType mDataMode; 
     private int mFixedColumns; 
     private ShowScrollDataMode mShowScrollDataMode; 
     private Unit ymScrollWidth; 
     public enum ShowScrollDataMode 
     { 
       XScroll, 
       YScroll, 
       Both, 
       None, 
     } 
     public enum DataModeType 
     { 
       可変行Scroll, 
       固定行Scroll, 
     }  [NotifyParentProperty(true), Browsable(false), EditorBrowsable(EditorBrowsableState.Advanced)] 
     public bool AutoGenerateColumns { 
       get { 
         return base.AutoGenerateColumns; 
       } 
       set { 
         base.AutoGenerateColumns = false; 
       } 
     }  [NotifyParentProperty(true), Browsable(false), EditorBrowsable(EditorBrowsableState.Advanced)] 
     public new string DataMember { 
       get { 
         return base.DataMember; 
       } 
       set { 
         base.DataMember = Value; 
       } 
     }  [NotifyParentProperty(true)] 
     public bool AllowCustomPaging { 
       get { 
         return base.AllowCustomPaging; 
       } 
       set { 
         base.AllowCustomPaging = Value; 
       } 
     }  [NotifyParentProperty(true)] 
     public bool AllowPaging { 
       get { 
         return base.AllowPaging; 
       } 
       set { 
         base.AllowPaging = Value; 
       } 
     }  [NotifyParentProperty(true), Browsable(false), EditorBrowsable(EditorBrowsableState.Advanced)] 
     public bool AllowSorting { 
       get { 
         return base.AllowSorting; 
       } 
       set { 
         base.AllowSorting = Value; 
       } 
     }  [NotifyParentProperty(true)] 
     public TableItemStyle AlternatingItemStyle { 
       get { 
         return base.AlternatingItemStyle; 
       } 
     }  [NotifyParentProperty(true)] 
     public Color BackColor { 
       get { 
         return base.BackColor; 
       } 
       set { 
         base.BackColor = Value; 
       } 
     }  [NotifyParentProperty(true)] 
     public string BackImageUrl { 
       get { 
         return base.BackImageUrl; 
       } 
       set { 
         base.BackImageUrl = Value; 
       } 
     }  [NotifyParentProperty(true)] 
     public Color BorderColor { 
       get { 
         return base.BorderColor; 
       } 
       set { 
         base.BorderColor = Value; 
       } 
     }  [NotifyParentProperty(true)] 
     public BorderStyle BorderStyle { 
       get { 
         return base.BorderStyle; 
       } 
       set { 
         base.BorderStyle = Value; 
       } 
     }  [NotifyParentProperty(true)] 
     public Unit BorderWidth { 
       get { 
         return base.BorderWidth; 
       } 
       set { 
         base.BorderWidth = Value; 
       } 
     }  [NotifyParentProperty(true)] 
     public int CellPadding { 
       get { 
         return base.CellPadding; 
       } 
       set { 
         base.CellPadding = Value; 
       } 
     }  [NotifyParentProperty(true)] 
     public int CellSpacing { 
       get { 
         return base.CellSpacing; 
       } 
       set { 
         base.CellSpacing = Value; 
       } 
     }  [NotifyParentProperty(true)] 
     public DataGridColumnCollection Columns { 
       get { 
         return base.Columns; 
       } 
     } 
      

  19.   

    [NotifyParentProperty(true)] 
     public int EditItemIndex { 
       get { 
         return base.EditItemIndex; 
       } 
       set { 
         base.EditItemIndex = Value; 
       } 
     }  [NotifyParentProperty(true)] 
     public TableItemStyle EditItemStyle { 
       get { 
         return base.EditItemStyle; 
       } 
     }  [NotifyParentProperty(true)] 
     public bool Enabled { 
       get { 
         return base.Enabled; 
       } 
       set { 
         base.Enabled = Value; 
       } 
     }  [NotifyParentProperty(true)] 
     public TableItemStyle FooterStyle { 
       get { 
         return base.FooterStyle; 
       } 
     }  [NotifyParentProperty(true)] 
     public Color ForeColor { 
       get { 
         return base.ForeColor; 
       } 
       set { 
         base.ForeColor = Value; 
       } 
     }  [NotifyParentProperty(true)] 
     public GridLines GridLines { 
       get { 
         return base.GridLines; 
       } 
       set { 
         base.GridLines = Value; 
       } 
     }  [NotifyParentProperty(true)] 
     public TableItemStyle HeaderStyle { 
       get { 
         return base.HeaderStyle; 
       } 
     }  [NotifyParentProperty(true)] 
     public Unit Height { 
       get { 
         return base.Height; 
       } 
       set { 
         base.Height = Value; 
       } 
     }  [NotifyParentProperty(true)] 
     public HorizontalAlign HorizontalAlign { 
       get { 
         return base.HorizontalAlign; 
       } 
       set { 
         base.HorizontalAlign = Value; 
       } 
     }  [NotifyParentProperty(true)] 
     public TableItemStyle ItemStyle { 
       get { 
         return base.ItemStyle; 
       } 
     }  [NotifyParentProperty(true)] 
     public DataGridPagerStyle PagerStyle { 
       get { 
         return base.PagerStyle; 
       } 
     }  [NotifyParentProperty(true)] 
     public int PageSize { 
       get { 
         return base.PageSize; 
       } 
       set { 
         base.PageSize = Value; 
       } 
     }  [NotifyParentProperty(true)] 
     public bool ShowFooter { 
       get { 
         return base.ShowFooter; 
       } 
       set { 
         base.ShowFooter = Value; 
       } 
     }  [NotifyParentProperty(true)] 
     public bool ShowHeader { 
       get { 
         return base.ShowHeader; 
       } 
       set { 
         base.ShowHeader = Value; 
       } 
     }  [NotifyParentProperty(true)] 
     public bool Visible { 
       get { 
         return base.Visible; 
       } 
       set { 
         base.Visible = Value; 
       } 
     }  [NotifyParentProperty(true)] 
     public Unit Width { 
       get { 
         return base.Width; 
       } 
       set { 
         base.Width = Value; 
       } 
     }  [NotifyParentProperty(true)] 
     public string CssClass { 
       get { 
         return base.CssClass; 
       } 
       set { 
         base.CssClass = Value; 
       } 
     }  [Category("モード選択"), DefaultValue(typeof(Unit), "0px"), Description("スクロールの幅")] 
     public Unit YScrollBarHeight { 
       get { 
         return ymScrollWidth; 
       } 
       set { 
         ymScrollWidth = Value; 
       } 
     } 
      

  20.   

    [Category("モード選択"), DefaultValue(typeof(Unit), "0px"), Description("スクロールの幅")] 
     public Unit XScrollBarWidth { 
       get { 
         return mScrollWidth; 
       } 
       set { 
         mScrollWidth = Value; 
       } 
     }  [Category("モード選択"), DefaultValue(0), Description("固定行の個数")] 
     public int FixedColumns { 
       get { 
         if (mShowScrollDataMode == ShowScrollDataMode.XScroll) { 
           return mFixedColumns; 
         } 
       } 
       set { 
         if (mShowScrollDataMode == ShowScrollDataMode.XScroll) { 
           if (this.Columns.Count < Value & !this.Columns.Count == 0) { 
             mFixedColumns = this.Columns.Count; 
           } else if (Value < 0) { 
             mFixedColumns = 0; 
           } else { 
             mFixedColumns = Value; 
           } 
         } 
       } 
     }  [Category("モード選択"), DefaultValue(typeof(ShowScrollDataMode), "XScroll"), Description("XScroll")] 
     public ShowScrollDataMode ShowScrollMode { 
       get { 
         return mShowScrollDataMode; 
       } 
       set { 
         mShowScrollDataMode = Value; 
       } 
     }  protected void Render(System.Web.UI.HtmlTextWriter writer) 
     { 
       Hashtable tmpArrayList; 
       tmpArrayList = new Hashtable(); 
       tmpArrayList.Add("Z-INDEX", Style.Item("Z-INDEX")); 
       tmpArrayList.Add("LEFT", Style.Item("LEFT")); 
       tmpArrayList.Add("POSITION", Style.Item("POSITION")); 
       tmpArrayList.Add("TOP", Style.Item("TOP")); 
       this.Style.Remove("Z-INDEX"); 
       this.Style.Remove("LEFT"); 
       this.Style.Remove("POSITION"); 
       this.Style.Remove("TOP"); 
       writer.Write("<div" + " id='" + this.ID + "_All' style='"); 
       writer.Write("Z-INDEX: " + tmpArrayList("Z-INDEX") + ";"); 
       writer.Write("LEFT: " + tmpArrayList("LEFT") + ";"); 
       writer.Write("POSITION: " + tmpArrayList("POSITION") + ";"); 
       writer.Write("TOP: " + tmpArrayList("TOP") + "' ms_positioning = 'FlowLayout'>"); 
       FixedColumnDataGrid(writer); 
       writer.Write("</div>"); 
     }  private void FixedColumnDataGrid(System.Web.UI.HtmlTextWriter output) 
     { 
       string divStyle; 
       string widthOne; 
       string widthTwo; 
       string heightOne; 
       string heightTwo; 
       bool[] visiableColumn; 
       int k; 
       for (int i = 0; i <= this.Columns.Count - 1; i++) { 
         visiableColumn(i) = this.Columns(i).Visible; 
       } 
       k = 0; 
       for (int i = 0; i <= mFixedColumns - 1; i++) { 
         for (int j = k; j <= this.Columns.Count - 1; j++) { 
           if (this.Columns.Item(j).Visible) { 
             widthOne = System.Convert.ToString((Val(widthOne) + Val(this.Columns(j).HeaderStyle.Width.ToString))); 
             k = j + 1; 
             goto exitForStatement0; 
           } 
         } 
         exitForStatement0: ; 
       } 
       exitForStatement0: ; 
       widthOne = ((string)Val(widthOne) + 1 + Val(CellSpacing) * mFixedColumns); 
       if (mFixedColumns == 0) { 
         widthOne = "0"; 
       } 
       widthTwo = mScrollWidth.ToString; 
       heightTwo = mScrollWidth.ToString; 
       OutPutLayout(widthOne, widthTwo, heightOne, heightTwo, visiableColumn, output); 
     }  private void OutPutLayout(string widthOne, string widthTwo, string heightOne, string heightTwo, bool[] visiableColumn, System.Web.UI.HtmlTextWriter output) 
     { 
       output.Write("<table cellSpacing='0' cellPadding='0' border='0'>"); 
       if (ShowScrollMode == ShowScrollDataMode.None) { 
         output.Write("<tr>"); 
         if (!this.Columns.Count <= mFixedColumns) { 
           ShowLeft("", output); 
         } 
         output.Write("</tr>"); 
       } else if (ShowScrollMode == ShowScrollDataMode.XScroll) { 
         output.Write("<tr>"); 
         ShowLeft(widthOne, output); 
         if (!this.Columns.Count <= mFixedColumns) { 
           ShowRight(widthTwo, output); 
         } 
         output.Write("</tr>"); 
       } else if (ShowScrollMode == ShowScrollDataMode.YScroll) { 
         output.Write("<tr>"); 
         ShowTop(heightOne, output); 
         output.Write("</tr>"); 
         if (!this.Columns.Count <= mFixedColumns) { 
           output.Write("<tr>"); 
           ShowBottom(heightTwo, output); 
           output.Write("</tr>"); 
         } 
       } else if (ShowScrollMode == ShowScrollDataMode.Both) { 
         output.Write("<tr>"); 
         ShowTop(heightOne, output); 
         output.Write("</tr>"); 
         if (mFixedColumns == 0) { 
           output.Write("<tr>"); 
           BothScroll(heightTwo, output); 
           output.Write("</tr>"); 
         } 
       } 
       for (int i = 0; i <= this.Columns.Count - 1; i++) { 
         this.Columns.Item(i).Visible = visiableColumn(i); 
       } 
       output.Write("</table>"); 
     } 
      

  21.   

    private void BothScroll(string width, System.Web.UI.HtmlTextWriter output) 
     { 
       string divStyle; 
       output.Write("<td valign='top'>"); 
       divStyle = "<DIV id='" + this.ID + "_DivBottom' style='OVERFLOW-Y: scroll; OVERFLOW-X: scroll;HEIGHT: " + this.YScrollBarHeight.ToString + "; WIDTH: " + this.XScrollBarWidth.ToString + ";" + " BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; " + "' ms_positioning = 'GridLayout' > "; 
       output.Write(divStyle); 
       for (int i = 0; i <= this.Items.Count - 1; i++) { 
         this.Items(i).Visible = true; 
       } 
       for (int i = 0; i <= this.Items.Count - 1; i++) { 
         this.Items(i).Attributes("id") = this.ID + "TRD" + i; 
       } 
       this.Style("BORDER-STYLE") = "none"; 
       this.ShowHeader = false; 
       base.Render(output); 
       this.ShowHeader = true; 
       output.Write("</DIV>"); 
       output.Write("</td>"); 
     }  private void ShowLeft(string width, System.Web.UI.HtmlTextWriter output) 
     { 
       string divStyle; 
       output.Write("<td valign='top'>"); 
       divStyle = "<DIV id='" + this.ID + "_DivLeft' style='OVERFLOW-X: hidden; WIDTH: " + width + ";" + " BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; " + "' ms_positioning = 'GridLayout' > "; 
       output.Write(divStyle); 
       if (this.mShowScrollDataMode == ShowScrollDataMode.None) { 
         for (int i = 0; i <= this.Items.Count - 1; i++) { 
           this.Items(i).Attributes("id") = this.ID + "TRD" + i; 
         } 
       } else { 
         for (int i = 0; i <= this.Items.Count - 1; i++) { 
           this.Items(i).Attributes("id") = this.ID + "TRL" + i; 
         } 
       } 
       this.Style("BORDER-STYLE") = "none"; 
       base.Render(output); 
       output.Write("</DIV>"); 
       output.Write("</td>"); 
     }  private void ShowRight(string width, System.Web.UI.HtmlTextWriter output) 
     { 
       string divStyle; 
       output.Write("<td valign='top'>"); 
       divStyle = "<DIV id='" + this.ID + "_DivRight' style='OVERFLOW-X: scroll; WIDTH: " + width + ";" + " BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; " + "' ms_positioning = 'GridLayout' > "; 
       output.Write(divStyle); 
       if (!ShowScrollMode == ShowScrollDataMode.None) { 
         for (int i = 0; i <= mFixedColumns - 1; i++) { 
           for (int j = 0; j <= this.Columns.Count - 1; j++) { 
             if (this.Columns.Item(j).Visible) { 
               this.Columns.Item(j).Visible = false; 
               goto exitForStatement1; 
             } 
           } 
           exitForStatement1: ; 
         } 
         exitForStatement1: ; 
       } 
       for (int i = 0; i <= this.Items.Count - 1; i++) { 
         this.Items(i).Attributes("id") = this.ID + "TRR" + i; 
       } 
       this.Style("BORDER-STYLE") = "none"; 
       base.Render(output); 
       output.Write("</DIV>"); 
       output.Write("</td>"); 
     }  private void ShowTop(string height, System.Web.UI.HtmlTextWriter output) 
     { 
       string divStyle; 
       output.Write("<td valign='bottom'>"); 
       divStyle = "<DIV id='" + this.ID + "_DivTop' style='BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; " + "' ms_positioning = 'GridLayout' > "; 
       output.Write(divStyle); 
       for (int i = 0; i <= this.Items.Count - 1; i++) { 
         this.Items(i).Visible = false; 
       } 
       for (int i = 0; i <= this.Items.Count - 1; i++) { 
         this.Items(i).Attributes("id") = this.ID + "TRD" + i; 
       } 
       this.Style("BORDER-STYLE") = "none"; 
       this.ShowFooter = false; 
       base.Render(output); 
       output.Write("</DIV>"); 
       output.Write("</td>"); 
     }  private void ShowBottom(string height, System.Web.UI.HtmlTextWriter output) 
     { 
       string divStyle; 
       output.Write("<td valign='top'>"); 
       divStyle = "<DIV id='" + this.ID + "_DivBottom' style='OVERFLOW-Y: scroll; HEIGHT: " + this.YScrollBarHeight.ToString + ";" + " BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; " + "' ms_positioning = 'GridLayout' > "; 
       output.Write(divStyle); 
       for (int i = 0; i <= this.Items.Count - 1; i++) { 
         this.Items(i).Visible = true; 
       } 
       for (int i = 0; i <= this.Items.Count - 1; i++) { 
         this.Items(i).Attributes("id") = this.ID + "TRD" + i; 
       } 
       this.Style("BORDER-STYLE") = "none"; 
       this.ShowHeader = false; 
       base.Render(output); 
       this.ShowHeader = true; 
       output.Write("</DIV>"); 
       output.Write("</td>"); 
     } 
    }
      

  22.   

    to:rickjelly2004(rick & jelly)
     在使用這種方式時, 你是否注意到表頭與數據行對不齊?
    謝謝.
      

  23.   

    如果將表頭與數據放入一個table中, 就可對齊了,只用div 好像有問題
      

  24.   

    我做的控件中,主要是用了javascript對datagird進行了處理.效果很好
      

  25.   

    當showscrollmode=both, FixedColumns=1 時, 若有100條記錄, 那麼固定列的高度與右邊的不一致,
      

  26.   

    十分感谢:rickjelly2004(rick & jelly) 踏着高手的脚步继续学习……
      

  27.   

    ComponentOne 的吧?我们买了一套,功能强大极了,还提供代码。
      

  28.   

    今天參考了一下這個網站給的例子,非常簡單,非常實用,Good!http://www.codeproject.com/aspnet/FreezePaneDatagrid.asp
      

  29.   

    to:rickjelly2004(rick & jelly)
      如何才能使定義控件支持模板列?