* Control * DataGrid with horizontal and vertical scroll bars (horizontal support from the queue)

xiaoxiao2021-03-06  49

(Sorry, someone has to have a horizontal vertical, I can change it, I can have a horizontal and vertical scrolling, Q actually I feel unnecessary, or if I do it, I have to control it in the forum.) Currently in the forum There are a lot of people asking if there is a DataGrid of the scroll, so I have an urgent way to do it. Of course, the function is the scroll bar, but I have made it a good thing to find that the page is not okay, no way, I have time I still To give it a paging control, it is my code, interested people can take back, I will improve it, give it a paging (I can't do it, it is the page to go to the top), because I don't think much, time is very tight, there are many problems above, I hope everyone will change it. Usage: FixedColumns: You want to scroll through the horizontal direction, from which one list begins

ShowscrollMode: You want to scroll horizontally, or rolled up

XscrollBarwidth: Width of the roll bar yscrollbarwidth: the height of rolling bar

Remember, you set ShowscrollMode first, then ScrollBarwidth's width,

You may set fixedColumns to find a few columns in front of the previous column, because you didn't set the width of the previous column

So when you add a column, you have to add a width, will, the property editor, the property editor, you have two pagan when you have rolling, you can set the height of the horizontal roll It, huh, I haven't changed much time, I have to be a big project, I hope to forgive! Imports System.comPonentModelimports System.Web.uiImports System.drawingImports System.Webimports System.Web.ui.WebControls

")> _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 can be built Scroll fixed line Scroll End enum

#Region "プ プ パティ" #Region "Pro] れ れ れ 表示 表示 表示"

_ Public Overrides Property AutoGenerateColumns () As Boolean Get Return MyBase.AutoGenerateColumns End Get Set (ByVal Value As Boolean) MyBase.AutoGenerateColumns = False End Set End Property _ Public Shadows Property DataMember () As String Get Return MyBase.DataMember End Get Set (ByVal Value As String) MyBase.DataMember = Value End Set End Property

_ Public Overrides Property AllowCustomPaging () As Boolean Get Return MyBase.AllowCustomPaging End Get Set (ByVal Value As Boolean) MyBase.AllowCustomPaging = Value End Set End Property

_ public overrides property allowpaging () as boolean get return mybase.allowpaging end set (byval value as boolean) mybase.allowpaging = value End vendy

_ Public Overrides Property AllowSorting () As Boolean Get Return MyBase.AllowSorting End Get Set (ByVal Value As Boolean) MyBase.AllowSorting = Value End Set End Property

_ Public Overrides ReadOnly Property AlternatingItemStyle () As TableItemStyle Get Return MyBase.AlternatingItemStyle End Get End Property _ Public Overrides Property BackColor () As Color Get Return MyBase.BackColor End Get Set (ByVal Value as color) mybase.backcolor = value End set End Property

_ Public Overrides Property BackImageUrl () As String Get Return MyBase.BackImageUrl End Get Set (ByVal Value As String) MyBase.BackImageUrl = Value End Set End Property

_ Public Overrides Property BorderColor () AS Color Get Return MyBase.BorderColor End Get Set (Byval Value As Color) MyBase.BorderColor = Value End SET End Property

_ Public Overides Property Border () AS BORDERSTYLE END GET (BYVAL VALUE AS BORDERSTYLE) MyBASE.BORDERSTYLE = VALUE END SET End Property

_ public overrides property borderwidth () as unit get return mybase.borderwidth End get set (Byval value as unit) mybase.borderwidth = value end endproperty

_ Public Overrides Property CellPadding () As Integer Get Return MyBase.CellPadding End Get Set (ByVal Value As Integer) MyBase.CellPadding = Value End Set End Property _ Public Overrides Property CellSpacing ( ) AS integer Get Return mybase.cellspacing end set (byval value as integer) mybase.cellspacing = value end vendy

_ Public Overrides Readonly Property Column () AS DataGridColumnCollection Get Return MyBase.columns End Get Property

_ public overrides property edititemindex () AS integer get return mybase.edititemindex end set (byval value as integer) mybase.edititemindex = value end and

_ Public Overides Readonly Property EditItemStyle Get Return MyBase.editItemStyle End Get Property

_ public overrides property enabled () as boolean get return mybase.enabled end set (byval value as boolean) mybase.enabled = value end vendy

_ Public Overides Readonly Property Footerstyle () AS TableItemStyle Get Return MyBase.Footerstyle End Get Property

_ Public Overrides Property ForeColor () As Color Get Return MyBase.ForeColor End Get Set (ByVal Value As Color) MyBase.ForeColor = Value End Set End Property _ Public Overrides Property GridLines ( AS GridLines Get Return MyBase.GridLines End Get Set (Byval Value As Gridlines) MyBase.Gridlines = Value End SET End Property

_ Public Overrides Readonly Property Headerstyle () AS TableItemStyle Get Return MyBase.Headerstyle End Get Property

_ public overrides property height () as unit get return mybase.Height End get set (byval value as unit) mybase.height = value End set

_ Public Overrides Property HorizontalAlign () As HorizontalAlign Get Return MyBase.HorizontalAlign End Get Set (ByVal Value As HorizontalAlign) MyBase.HorizontalAlign = Value End Set End Property

_ Public Overides Readonly Property ItemStyle () AS TableItemStyle Get Return MyBase.ItemStyle End Get End Property

_ public overrides readonly property Pagerstyle () AS dataGridpagersty get return mybase.pagerstyle End get End Property

_ Public Overrides Property PageSize () As Integer Get Return MyBase.PageSize End Get Set (ByVal Value As Integer) MyBase.PageSize = Value End Set End Property _ Public Overrides Property ShowFooter ( ) As boolean get return mybase.showfooter end set (byval value as boolean) mybase.showfooter = value end vendy

_ Public Overrides Property Showheader () AS Boolean Get Return MyBase.Showheader End Get Set (Byval Value As Boolean) MyBase.ShowHeader = Value End End Property

_ public overrides property visible () as boolean get return mybase.visible end set (byval value as boolean) mybase.visible = value end vend @

_ public overrides protection width () as unit get return mybase.width end set (byval value as unit) mybase.width = value end vend w @ w

_ public overrides property cssclass () AS String get return mybase.cssclass end set (byval value as string) mybase.cssclass = value end vend = value end set entry # end region

_ Public Property YScrollBarHeight () As Unit Get Return ymScrollWidth End GetSet (ByVal Value As Unit) YMScrollWidth = Value End Set End Property

_ public property xscrollbarwidth () as unit get 'setting 値 戻 戻 戻 Return MscrollWidth End Get

Set (Byval Value As Unit) Set 値 MscrollWidth = Value End SET End Property

_ 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

_ Public Property ShowScrollMode () As ShowScrollDataMode Get Return mShowScrollDataMode End Get Set (ByVal Value As ShowScrollDataMode) mShowScrollDataMode = Value End Set and Property # endvalprotected 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 ("")

FIXEDCOLUMNDATAGRID (Writer) Writer.write ("") 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 IntegerReDim 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 the

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 ( "

") If ShowScrollMode = ShowScrollDataMode.None Then output.Write (" ") If Not Me.Columns.Count <= mFixedColumns Then Call ShowLeft ("" ", OUTPUT) END IF

output.Write ( "") ElseIf ShowScrollMode = ShowScrollDataMode.XScroll Then output.Write ( "

") Call ShowLeft (widthOne, output) If Not Me.Columns.Count <= mFixedColumns Then Call ShowRight (widthTwo Output) END IF OTPUT.WRITE ("") Elseif ShowscrollMode = ShowscrollDataMode.yscroll Then Output.write ("") showtop (Heightone, Output) Output.write ("") If Not Me.Columns.Count <= mFixedColumns Then output.Write ( "") Call ShowBottom (heightTwo, output) output.Write ( "") End If ElseIf ShowScrollMode = ShowScrollDataMode.Both Then output. Write ("") showtop ("") Output.write ("") IF mfixedColumns = 0 Then Output.write ("") Call Bothscroll (HeightTwo, Output) Output.write (" ") End if End if for i as integer = 0 to me.columns.count - 1 me.columns.item (i) .visible = VisiableColumn (i) Next Output.write (" ") End Subprivate Sub Bothscroll (BYVAL WIDTH AS STRING, BYVAL output as system.web.ui.htmltextwriter) DIM DIVSTYLE AS STRING

Output.write ("

DivStyle = "

" 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.showhead = false mybase.render (output) me.showheader = true

Output.write ("") Output.write ("") End Sub

Private Sub Showleft (Byval Output As String, Byval Output As System.Web.ui.htmlTextWriter) DIM DivStyle As String Output.write ("

) DivStyle ="
"Output.write (DivStyle)

If Me.mshowscrollDataMode = showscrollDataMode.none the for i as integer = 0 to me.items.count - 1 me.items (i) .attributes ("id") = me.id & "trd" & i nextelse 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 (" "Output.write (" ") End Sub

Private Sub Showright (Byval Output As String, Byval Output As System.Web.ui.htmlTextwriter) DIM DivStyle As String

Output.write ("

") DivStyle = "
"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.Itemns.columns.Itemns.Itemns.columns.Item (j) .visible = FALSE EXIT for end if next next end

For i as integer = 0 to me.items.count - 1 me.items (i) .attributes ("id") = me.id & "tryl" & i next me.style ("border-style") = " None "mybase.render (output) Output.write (" ") Output.write (" ") End Subprivate Sub Showtop (Byval Height As String, Byval Output As System.Web.ui.htmlTextwriter )

DIM DivStyle As String

Output.write ("

DivStyle = "

"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 (" ") Output .Write ("") End Sub

Private Sub Showbottom (Byval Height As String, Byval Output As System.Web.ui.htmlTextwriter)

DIM DivStyle As String

Output.write ("

DivStyle = "

"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.showhead = false mybase.render (output) me.showheader = true

Output.write ("") Output.write ("") End Subend Class

转载请注明原文地址:https://www.9cbs.com/read-81072.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.034, SQL: 9