📄 modattachflexgrid.bas
字号:
Attribute VB_Name = "ModAttachFlexGrid"
Option Explicit
'**************************************************************
'*模块名称:ModAttachFlexGrid
'*模块功能:将FlexGrid中的数据添加到报表类
'*说明:
'*
'*备注:
'*
'*作者:chlf78
'*日期:2002-04-09 18:54:58
'***************************************************************
Private Const ModalName = "ModAttachFlexGrid"
'**************************************************************
'*名称:AttachFlexGrid
'*功能:将FlexGrid(MSHFlexGrid)中的数据添加到报表类
'*传入参数:
'* rpt --报表类
'* flexgrid --网格控件
'*返回参数:
'* 是否成功
'*作者:chlf78
'*日期:2002-04-09 18:58:40
'**************************************************************
Public Function funAttachFlexGrid(rpt As Report, flexgrid As Object) As Boolean
Dim i As Integer
Dim j As Integer
Dim cell As clsCell '*单元格
Dim cellnew As clsCellNew
Dim col As Integer
Dim cText As clsText
Dim alignColHeader As typeAlign '*列头对齐方式
Dim alignCol As typeAlign '*列对齐方式
On Error GoTo err_proc
With flexgrid
col = 0
For i = 1 To .Cols
'*先对控件进行处理...
'*如果未定义过列宽(即列宽值为-1),则设置为1005
If .colWidth(i - 1) = -1 Then
.colWidth(i - 1) = 1005
End If
'*列的对齐方式的设置,如果为字符串左对齐,数据右对齐,则设置为左对齐
If .ColAlignment(i - 1) = 9 Then
.ColAlignment(i - 1) = 1
End If
'*列头 (如果为字符串左对齐,数据右对齐,则设置为居中对齐)
If .ColAlignmentHeader(0, i - 1) = 9 Then
.ColAlignmentHeader(0, i - 1) = 3
End If
If .colWidth(i - 1) > LEASTWIDTH Then
col = col + 1
End If
Next i
'*设置对象的行列数
rpt.ColHeader.SetColRows col, .FixedRows
rpt.Content.SetColRows col, .rows - .FixedRows
col = 0
For i = 1 To .Cols
If .colWidth(i - 1) > LEASTWIDTH Then
col = col + 1
'*取列头对齐和列对齐方式
alignColHeader = tymiddle ' Int(.ColAlignmentHeader(0, i - 1) / 3)
alignCol = Int(.ColAlignment(i - 1) / 3)
.col = i - 1
'*列头
For j = 1 To .FixedRows
.row = j - 1
Set cell = New clsCell
With cell
.colFrom = col
.colTo = col
.rowFrom = j
.rowTo = j
.text.drawBorder = True
.text.stringX = flexgrid.TextMatrix(j - 1, i - 1)
.text.Align = alignColHeader
.text.width = flexgrid.colWidth(i - 1)
.text.height = flexgrid.rowheight(j - 1)
.text.rowheight = .text.height
.text.ForeColor = flexgrid.CellForeColor
End With
rpt.ColHeader.SetCell cell
Set cell = Nothing
Next j
'*设置正文的列属性
.row = flexgrid.FixedRows
Set cText = New clsText
With cText
.rowheight = flexgrid.rowheight(flexgrid.FixedRows)
.width = flexgrid.colWidth(i - 1)
.drawBorder = True
.Align = alignCol
.ForeColor = flexgrid.CellForeColor
rpt.Content.SetColText col, cText
End With
Set cText = Nothing
'*正文
For j = 1 To .rows - .FixedRows
Set cellnew = New clsCellNew
With cellnew
.colFrom = col
.colTo = col
.rowFrom = j
.rowTo = j
.stringX = flexgrid.TextMatrix(j + flexgrid.FixedRows - 1, i - 1)
.height = flexgrid.rowheight(j + flexgrid.FixedRows - 1)
End With
rpt.Content.SetCell cellnew
Set cellnew = Nothing
Next j
'*设置合并列
If .mergeCol(i - 1) Then
rpt.Content.SetMergeCol col, True
End If
End If
Next i
End With
funAttachFlexGrid = True
Exit Function
err_proc:
funAttachFlexGrid = False
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -