zoukankan      html  css  js  c++  java
  • 我最近写的DataGrid合并/删除相同列通用函数,跟大家分享

    鉴于相当多页面都要做合并列,我最近写了DataGrid合并/删除相同列通用函数,跟大家分享。
        Public Shared Sub DBGridSpanCell(ByRef dgdData As DataGrid, _
                                         ByVal intColumnItem As Integer, _
                                         ByVal intColumnStart As Integer, _
                                         ByVal intColumnEnd As Integer, _
                                         Optional ByVal intSpan As Integer = 2)
            '名称:DBGridSpanCell
            '功能:合并/删除相同的项目名
            '作者:dzt
            '创建:2004/1/1
            '修改:2004/1/1
            '参数:dgdData:DataGrid对象
            '      intColumnItem:要合并列
            '      intColumnStart:合并起始列
            '      intColumnEnd:合并结束列
            '      intSpan:跨行数
            '返回:成功,True,反之,False
            '说明:

            Dim i As Integer
            Dim o_intCols As Integer
            Dim iSpan As Integer = intSpan '跨行数
            Dim iRow As Integer = 0 '开始的跨行
            Dim sItem As String
            Dim sColumnText As String
            Dim ColumnType As Type
            Dim ctl As System.Web.UI.Control

            With dgdData.Items
                For i = 0 To .Count - 1
                    With .Item(i)
                        ColumnType = dgdData.Columns(intColumnItem).GetType
                        '模板列,label
                        If ColumnType Is GetType(TemplateColumn) Then
                            For Each ctl In dgdData.Items(i).Cells(intColumnItem).Controls
                                If ctl.GetType Is GetType(Label) Then
                                    sColumnText = CType(ctl, Label).Text
                                    Exit For
                                End If
                            Next
                        Else
                            sColumnText = .Cells(intColumnItem).Text
                        End If

                        ' If .Cells(intColumnItem).Text = sItem Then
                        If sColumnText = sItem Then
                            For o_intCols = intColumnStart To intColumnEnd
                                dgdData.Items(iRow).Cells(o_intCols).RowSpan = iSpan
                                .Cells(o_intCols).Visible = False
                            Next

                            iSpan += 1
                        Else
                            iRow = i
                            iSpan = intSpan
                            'sItem = .Cells(intColumnItem).Text
                            sItem = sColumnText
                        End If
                    End With
                Next
            End With
        End Sub

  • 相关阅读:
    用C#实现在线升级
    wordwrap,wordbreak,whitespace,textoverflow的区别和用法[转]
    Sql Server 存储过程分页大全(2005,2000)
    C#中生成中文繁体web页面
    如何在c#里执行sql server DTS包
    asp.net采集函数(采集、分析、替换、入库)
    css定义一个导航栏
    mssql与access的sql语法差异
    [转]sql server数据库定时自动备份
    HttpHandler与图片盗链
  • 原文地址:https://www.cnblogs.com/unruledboy/p/10460.html
Copyright © 2011-2022 走看看