Print_MSHFGrid1,这个打印控件怎么设置纸张大小,
打印时,如果代码写成设置30行就提示超出纸张大小 Print_MSHFGrid1.LeftSpace = 400
Print_MSHFGrid1.TopSpace = 400
Print_MSHFGrid1.FontSize = 12
Print_MSHFGrid1.Title = ""
Print_MSHFGrid1.ExTitle = " "
Print_MSHFGrid1.TitleFontSize = 20
Print_MSHFGrid1.ppRows = 30
Print_MSHFGrid1.UniteCellAlign = wcdCenterCenter
打印时,如果代码写成设置30行就提示超出纸张大小 Print_MSHFGrid1.LeftSpace = 400
Print_MSHFGrid1.TopSpace = 400
Print_MSHFGrid1.FontSize = 12
Print_MSHFGrid1.Title = ""
Print_MSHFGrid1.ExTitle = " "
Print_MSHFGrid1.TitleFontSize = 20
Print_MSHFGrid1.ppRows = 30
Print_MSHFGrid1.UniteCellAlign = wcdCenterCenter
VERSION 5.00
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
Object = "{5A727218-0B49-4D26-AD4E-4D6340511CED}#1.0#0"; "Print_MSHFlexGrid.ocx"
Begin VB.Form Form1
Caption = "MSHFGrid控件测试"
ClientHeight = 5520
ClientLeft = 60
ClientTop = 345
ClientWidth = 7875
LinkTopic = "Form1"
ScaleHeight = 5520
ScaleWidth = 7875
StartUpPosition = 2 'CenterScreen
Begin Print_MSHFlexGrid.Print_MSHFGrid Print_MSHFGrid1
Height = 735
Left = 60
TabIndex = 6
Top = 4440
Width = 735
_ExtentX = 1296
_ExtentY = 1296
TopSpace = 400
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
TitleFontSize = 14
End
Begin VB.PictureBox Picture1
Appearance = 0 'Flat
BackColor = &H00404040&
BorderStyle = 0 'None
ForeColor = &H80000008&
Height = 255
Left = 1200
ScaleHeight = 255
ScaleWidth = 735
TabIndex = 4
Top = 120
Visible = 0 'False
Width = 735
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "移动列"
ForeColor = &H00FFFFFF&
Height = 255
Left = 60
TabIndex = 5
Top = 0
Width = 555
End
End
Begin VB.CommandButton Command3
Caption = "退出"
Height = 435
Left = 6180
TabIndex = 3
Top = 4440
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "直接打印"
Height = 435
Left = 4800
TabIndex = 2
Top = 4440
Width = 1155
End
Begin VB.CommandButton Command1
Caption = "预览"
Height = 435
Left = 3300
TabIndex = 1
Top = 4440
Width = 1275
End
Begin MSHierarchicalFlexGridLib.MSHFlexGrid MSHFlexGrid1
Height = 4275
Left = 60
TabIndex = 0
Top = 60
Width = 7755
_ExtentX = 13679
_ExtentY = 7541
_Version = 393216
FixedCols = 0
FocusRect = 2
AllowUserResizing= 1
_NumberOfBands = 1
_Band(0).Cols = 2
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'///MshFGrid打印控件测试。
'///支持横向合并,对齐方式由MSHFGrid中的ColAlignment属性决定,
'///<3左对齐,>6右对齐,其它中间对齐
'///可以在预览时调调整列宽。
'///e-Mail:[email protected]
'///控件在测试阶段,有什么意见可以跟我联系,谢谢!。
Private r1 As Integer
Private Sub Command2_Click()
If Print_MSHFGrid1.LoadData(MSHFlexGrid1) = True Then
Print_MSHFGrid1.PrintMshF
End If
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim i, r As Long
With MSHFlexGrid1
.Rows = 13
.Cols = 6
For i = 0 To 5
.ColWidth(i) = 1002
.ColAlignment(i) = 6
Next i
.ColAlignment(4) = 2
For r = 0 To 12
.RowHeight(r) = 300
For i = 0 To 5
.TextMatrix(r, i) = r & i
Next i
Next r
.ColAlignmentFixed(0) = 4
.ColAlignmentFixed(1) = 6
.MergeCells = 1
.MergeRow(2) = True
.MergeRow(0) = True
.TextMatrix(0, 0) = "标题一"
.TextMatrix(0, 1) = "标题一"
.TextMatrix(2, 0) = "我要合并"
.TextMatrix(2, 1) = "我要合并"
.TextMatrix(2, 2) = "我要合并"
.TextMatrix(2, 3) = "我要合并"
.MergeRow(3) = True
.TextMatrix(3, 0) = "我也合"
.TextMatrix(3, 1) = "我也合"
.MergeRow(5) = True
.TextMatrix(5, 0) = "y合并y"
.TextMatrix(5, 1) = "y合并y"
.ColAlignmentFixed(5) = 2
End With
End Sub
Private Sub MSHFlexGrid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If MSHFlexGrid1.MouseRow <> 0 Then Exit Sub
r1 = MSHFlexGrid1.MouseCol
Picture1.Visible = True
End Sub
Private Sub MSHFlexGrid1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If r1 <> Empty Then
Picture1.Left = X
End If
End Sub
Private Sub MSHFlexGrid1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim dd As Long
If r1 = Empty Then Exit Sub
MSHFlexGrid1.ColPosition(MSHFlexGrid1.MouseCol) = r1
r1 = 0
Picture1.Visible = False
End Sub
Private Sub Command1_Click()
Print_MSHFGrid1.LeftSpace = 400 '//左边距
Print_MSHFGrid1.TopSpace = 400 '//顶边距
Print_MSHFGrid1.FontSize = 9
Print_MSHFGrid1.Title = "第一行标题在这里设"
Print_MSHFGrid1.ExTitle = "第二行标题" '//如果标题要两行显示,第二行设置
Print_MSHFGrid1.TitleFontSize = 20 '//标题字体大小
Print_MSHFGrid1.ppRows = 5 '//设置每页打印几行
Print_MSHFGrid1.UniteCellAlign = wcdCenterCenter '//合并后的对齐方式
Print_MSHFGrid1.SubTitleCount = 2 '//有两行副标题
Print_MSHFGrid1.SetSubTitleText 0, "日期:" & Date$, "部门:产品研发部", "级别"
Print_MSHFGrid1.SetSubTitleText 1, "审核:", "进度:", ""
Print_MSHFGrid1.FootCount = 1 '//有一行脚注。
Print_MSHFGrid1.SetFootText 0, "领导:", "", "财务:"
'Print_MSHFGrid1.PCode = "第&p页/总&t页" '//可以这样设页码
Print_MSHFGrid1.Orientation = 1 '//纵向打印
'//在打印和预览之前要使用方法LoadData赋值,参数说明MSHFGrid的名称
'//在调用方法之前要设好属性
If Print_MSHFGrid1.LoadData(MSHFlexGrid1) = True Then '
Print_MSHFGrid1.PreviewGrid '//预览表格
End If
End Sub