?? modattachdatagrid.bas
字號:
Attribute VB_Name = "ModAttachdatagrid"
Option Explicit
'**************************************************************
'*模塊名稱:ModAttachdataGrid
'*模塊功能:將dataGrid中的數據添加到報表類
'*說明:
'*
'*備注:
'*
'*作者:progame
'*日期:2002-04-09 18:54:58
'***************************************************************
Private Const ModalName = "ModAttachdataGrid"
'**************************************************************
'*名稱:AttachdataGrid
'*功能:將FlexGrid(dataGrid)中的數據添加到報表類
'*傳入參數:
'* rpt --報表類
'* datagrid --網格控件
'*返回參數:
'* 是否成功
'*作者:progame
'*日期:2002-04-09 18:58:40
'**************************************************************
Public Function funAttachdataGrid(rpt As report, datagrid 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 datagrid
col = 0
For i = 1 To .Columns.count
'*先對控件進行處理...
'*如果未定義過列寬(即列寬值為-1),則設置為1005
If .Columns(i - 1).width = 0 Then
.Columns(i - 1).width = 1005
End If
'*列的對齊方式的設置,如果為字符串左對齊,數據右對齊,則設置為左對齊
If .Columns(i - 1).alignment = 9 Then
.Columns(i - 1).alignment = 1
End If
'*列頭 (如果為字符串左對齊,數據右對齊,則設置為居中對齊)
If .Columns(i - 1).width > LEASTWIDTH Then
col = col + 1
End If
Next i
'*設置對象的行列數
rpt.ColHeader.SetColRows col, 1
rpt.Content.SetColRows col, .VisibleRows
col = 0
For i = 1 To .Columns.count
If .Columns(i - 1).width > LEASTWIDTH Then
col = col + 1
'*取列頭對齊和列對齊方式
alignColHeader = tymiddle ' Int(.ColAlignmentHeader(0, i - 1) / 3)
alignCol = Int(.Columns(i - 1).alignment / 3)
.col = i - 1
'*列頭
For j = 1 To 1
.row = j - 1
Set cell = New clsCell
With cell
.colFrom = col
.colTo = col
.rowFrom = j
.rowTo = j
.text.drawBorder = True
.text.stringX = datagrid.Columns(i - 1).Caption
.text.Align = alignColHeader
.text.width = datagrid.Columns(i - 1).width
'.text.height = datagrid.rowheight(j - 1)
.text.rowheight = datagrid.rowheight
'.text.ForeColor = datagrid.CellForeColor
End With
rpt.ColHeader.SetCell cell
Set cell = Nothing
Next j
'*設置正文的列屬性
.row = 0
Set cText = New clsText
With cText
.rowheight = datagrid.rowheight
.width = datagrid.Columns(i - 1).width
.drawBorder = True
.Align = alignCol
'.ForeColor = datagrid.CellForeColor
rpt.Content.SetColText col, cText
End With
Set cText = Nothing
'*正文
For j = 1 To .VisibleRows
Set cellnew = New clsCellNew
With cellnew
.colFrom = col
.colTo = col
.rowFrom = j
.rowTo = j
datagrid.row = j - 1
.stringX = "" & datagrid.Columns(i - 1).text
.height = datagrid.rowheight
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
funAttachdataGrid = True
Exit Function
err_proc:
funAttachdataGrid = False
MsgBox Err.Description & Err.Number
End Function
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -