配色: 字号:
VB中VSPrinter
2013-07-03 | 阅:  转:  |  分享 
  
VB中VSPrinter,VSFlexGrid控件使用2008-09-1013:17:34|分类:软件包|标签:|字号大



小订阅





PrivateSubForm_Load()

DimiAsLong

WithVSFlexGrid1

.WordWrap=True

.Rows=60

.Cols=8

.FixedRows=2

.FixedCols=0

.ColWidth(0)=1500

.RowHeight(0)=300

.RowHeight(1)=300

.TextMatrix(1,1)="进货"

.TextMatrix(1,2)="销售"

.TextMatrix(1,3)="退货"

.TextMatrix(1,4)="结存"

Fori=1To.Rows-1

.RowHeight(i)=300''设置行高

Nexti

Fori=0To1

.TextMatrix(i,0)="上月"&vbCrLf&"结存数量"''//换行

.FixedAlignment(0)=4

Nexti

Fori=0To1

.TextMatrix(i,5)="月末结存"

.FixedAlignment(5)=4

Nexti

Fori=1To4

.TextMatrix(0,i)="本月进销存数量"

.ColAlignment(i)=4

Nexti

.MergeCells=flexMergeFree''

.MergeCells=flexMergeFixedOnly

.MergeCol(0)=True

.MergeRow(0)=True

.MergeCol(5)=True



.ColComboList(5)="A||B||C"

.FocusRect=flexFocusNone

.Editable=flexEDKbd

.Cell(flexcpCustomFormat,3,0,3,VSFlexGrid1.Cols-1)="##.00000"

.Cell(flexcpBackColor,3,0,3,VSFlexGrid1.Cols-1)=vbRed''底色



i=2

Whilei>.Rows-1

.TextMatrix(i,1)=Str(i)

Wend

EndWith



EndSub



PrivateSubForm_Resize()

OnErrorResumeNext



VSPrinter1.Width=Me.ScaleWidth-100

VSPrinter1.Left=30

EndSub







PrivateSubVSFlexGrid1_Click()

VSFlexGrid1.ZOrder0

EndSub



PrivateSubVSPrinter1_Click()

DimoVsGridAsVSFlexGrid

DimOldColorAsLong



SetoVsGrid=VSFlexGrid1



OldColor=oVsGrid.BackColorFixed



oVsGrid.BackColorFixed=vbWhite

oVsGrid.Cell(flexcpBackColor,oVsGrid.FixedRows,oVsGrid.FixedCols,oVsGrid.Rows-1,VSFlexGrid1.Cols-1)=vbWhite''底色



WithVSPrinter1

.ZOrder0

.PaperSize=pprA4



''.Orientation=orLandscape''配置横向打印4010

''.TableBorder=tbAll



''配置页面四边的边距

.MarginTop=3200

.MarginBottom=1000

.MarginLeft=1400

.MarginRight=1400





.StartDoc

.TextAlign=taCenterMiddle

.RenderControl=oVsGrid.hWnd''把网格内容传递给vsView显示



.EndDoc



Fori=1To.PageCount

.StartOverlayi

.TextAlign=taCenterMiddle

.FontName="黑体"

.FontSize=20

.CurrentY=.MarginTop-1700

.Text="XXX报表"

.CurrentX=1600

.CurrentY=.MarginTop-300

.TextAlign=taLeftTop

.FontName="宋体"

.FontSize=12

.Text="页首:"

.FontSize=10

.FontName="宋体"

.TextAlign=taRightTop

.Text=i&"/"&.PageCount

.CurrentX=1600

.CurrentY=.PageHeight-.MarginBottom+50

.FontName="宋体"

.FontSize=10

.TextAlign=taLeftBottom

.Text="页脚1"

.FontSize=10

.FontName="宋体"

.TextAlign=taRightBottom

.Text="页脚2"

.FontSize=10

.FontName="宋体"

.TextAlign=taRightBottom

.Text="打印日期:"&Format(Date,"yyyy年mm月dd日")

.EndOverlay



Nexti







EndWith



oVsGrid.BackColorFixed=OldColor

EndSub







''带目录结构的表格

SubLoadTree(oVsGridAsVSFlexGrid)

WithoVsGrid

.Subtotal(0)''&&清除表格汇总

.Cols=5''&&设置列数

.Rows=1+5^4''&&设置行数注:从第零行开始

.FixedRows=1''&&设置固定行数(第零行)

.FixedCols=1''&&设置固定列数(第零列)

.ColWidth(0)=0''&&设置第一列的宽度为零

.Clear''&&清除表格中的数据。



.AllowUserResizing=1''&&flexResizeColumns只允许调整列宽

.OutlineBar=1''&&左边树型的样式,显示分层数和线条

.OutlineCol=0''&&在哪列显示分层

.MergeCells=7''&&flexMergeOutline合并方式



''--设定标题行的四个标题

.TextMatrix(0,1)="第一层"

.TextMatrix(0,2)="第二层"

.TextMatrix(0,3)="第三层"

.TextMatrix(0,4)="显示数据"



Dima,b,c,d,rAsInteger



''--设置三层循环,加载数据

r=0

Fora=1To5

Forb=1To5

Forc=1To5

Ford=1To5

r=r+1

.TextMatrix(r,1)="a"+Trim(Str(a))

.TextMatrix(r,2)="a"+Trim(Str(a))+"b"+Trim(Str(b))

.TextMatrix(r,3)="a"+Trim(Str(a))+"b"+Trim(Str(b))+"c"+Trim(Str(c))

.TextMatrix(r,4)=""

Nextd

Nextc

Nextb

Nexta

''--进行数据汇总,但是不汇总!第一个参数就是不统计,只是为了显示树

''第二个参数是列数,后面是前景,背景色,以及是否用粗体



.SubtotalflexSTNone,1,,,RGB(255,0,0),RGB(255,255,255),,,,True

.SubtotalflexSTNone,2,,,RGB(128,128,128),RGB(0,255,0),,,,True

.SubtotalflexSTNone,3,,,RGB(128,128,200),RGB(255,255,255),,,,True

EndWith

献花(0)
+1
(本文系adong2010.c...首藏)