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

  • 相关阅读:
    RecyclerView的通用适配器
    Service由浅到深——AIDL的使用方式
    Android热修复——Tinker的集成
    ListView ,GridView 通用适配器
    Android开发者必知的5个开源库
    Android下强制打开键盘
    Android下强制打开软键盘
    怎么监听Android软键盘的打开和关闭
    【转】ListView 3D翻页效果
    Android 手动显示和隐藏软键盘
  • 原文地址:https://www.cnblogs.com/unruledboy/p/10460.html
Copyright © 2011-2022 走看看