?? modattachflexgrid.bas
字號(hào):
Attribute VB_Name = "ModAttachFlexGrid"
Option Explicit
'**************************************************************
'*模塊名稱(chēng):ModAttachFlexGrid
'*模塊功能:將FlexGrid中的數(shù)據(jù)添加到報(bào)表類(lèi)
'*說(shuō)明:
'*
'*備注:
'*
'*作者:progame
'*日期:2002-04-09 18:54:58
'***************************************************************
Private Const ModalName = "ModAttachFlexGrid"
'**************************************************************
'*名稱(chēng):AttachFlexGrid
'*功能:將FlexGrid(MSHFlexGrid)中的數(shù)據(jù)添加到報(bào)表類(lèi)
'*傳入?yún)?shù):
'* rpt --報(bào)表類(lèi)
'* flexgrid --網(wǎng)格控件
'*返回參數(shù):
'* 是否成功
'*作者:progame
'*日期: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 '*列頭對(duì)齊方式
Dim alignCol As typeAlign '*列對(duì)齊方式
On Error GoTo err_proc
With flexgrid
col = 0
For i = 1 To .Cols
'*先對(duì)控件進(jìn)行處理...
'*如果未定義過(guò)列寬(即列寬值為-1),則設(shè)置為1005
If .colWidth(i - 1) = -1 Then
.colWidth(i - 1) = 1005
End If
'*列的對(duì)齊方式的設(shè)置,如果為字符串左對(duì)齊,數(shù)據(jù)右對(duì)齊,則設(shè)置為左對(duì)齊
If .ColAlignment(i - 1) = 9 Then
.ColAlignment(i - 1) = 1
End If
'*列頭 (如果為字符串左對(duì)齊,數(shù)據(jù)右對(duì)齊,則設(shè)置為居中對(duì)齊)
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
'*設(shè)置對(duì)象的行列數(shù)
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
'*取列頭對(duì)齊和列對(duì)齊方式
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.fontsize = 11
.text.rowheight = .text.height
.text.ForeColor = flexgrid.CellForeColor
End With
rpt.ColHeader.SetCell cell
Set cell = Nothing
Next j
'*設(shè)置正文的列屬性
.row = flexgrid.FixedRows
Set cText = New clsText
With cText
.rowheight = flexgrid.rowheight(flexgrid.FixedRows)
.width = flexgrid.colWidth(i - 1)
.drawBorder = True
.Align = alignCol
.autowrap = False
.autoTrim = True
.ForeColor = flexgrid.CellForeColor
.fontsize = 10
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
If .mergeRow(j) Then
'rpt.Content.SetMergerow j, True
End If
rpt.Content.SetCell cellnew
Set cellnew = Nothing
Next j
'*設(shè)置合并列
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
MsgBox Err.Number & Err.Description
End Function
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -