预览加载中,请您耐心等待几秒...
1/10
2/10
3/10
4/10
5/10
6/10
7/10
8/10
9/10
10/10

亲,该文档总共26页,到这已经超出免费预览范围,如果喜欢就直接下载吧~

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

VB数据库编程中MSHFlexGrid控件用法详解 添加MSHFlexGrid将Name改成flex1 添加text将name改成txtedit Publicrs1AsNewADODB.Recordset,rs2AsNewADODB.Recordset'定义数据集对象 DimiAsInteger,jAsInteger SubEditKeyCode(MSHFlexGridAsControl,EdtAsControl,KeyCodeAsInteger,ShiftAsInteger) '标准编辑控件处理。 SelectCaseKeyCode Case27'ESC:隐藏焦点并将其返回MSFlexGrid Edt.Visible=False MSHFlexGrid.SetFocus Case13'ENTER将焦点返回MSFlexGrid。 MSHFlexGrid.SetFocus DoEvents IfMSHFlexGrid.Col<MSHFlexGrid.Cols-1Then MSHFlexGrid.Col=MSHFlexGrid.Col+1 Else IfMSHFlexGrid.Col=MSHFlexGrid.Cols-1Then MSHFlexGrid.Row=MSHFlexGrid.Row+1 MSHFlexGrid.Col=1 EndIf EndIf Case38'向上 MSHFlexGrid.SetFocus DoEvents IfMSFlexGrid.Row>MSFlexGrid.FixedRowsThen MSFlexGrid.Row=MSFlexGrid.Row-1 EndIf EndSelect EndSub Subview_DP() Ifflex1.Col=4Orflex1.Col=5Orflex1.Col=6Then '格式化Flex1表的第7列、第8列、第9列、第11列 flex1.TextMatrix(flex1.Row,5)=Format(flex1.TextMatrix(flex1.Row,5),"0.00") flex1.TextMatrix(flex1.Row,6)=Val(flex1.TextMatrix(flex1.Row,4))*Val(flex1.TextMatrix(flex1.Row,5)) flex1.TextMatrix(flex1.Row,6)=Format(flex1.TextMatrix(flex1.Row,6),"0.00") EndIf DimA,BAsSingle'声明单精度浮点型变量 OnErrorResumeNext Fori=1Toflex1.Rows-1 Ifflex1.TextMatrix(i,1)<>""Andflex1.TextMatrix(i,4)<>""Andflex1.TextMatrix(i,6)<>""Then A=Val(flex1.TextMatrix(i,6))+A'求合计金额 B=Val(flex1.TextMatrix(i,4))+B'求合计数量 EndIf Nexti lblCount=B lblSum=Format(A,"0.00")'格式化合计金额 EndSub SubSetButtons(bValAsBoolean) cmdRegister.Enabled=NotbVal cmdSave.Enabled=bVal cmdCancel.Enabled=bVal flex1.Enabled=bVal Frame1.Enabled=bVal EndSub PrivateSubDataGrid2_KeyDown(KeyCodeAsInteger,ShiftAsInteger) IfKeyCode=vbKeyReturnThen WithAdodc2.Recordset '赋值给flex1表格 If.Fields("商品名称")<>""Thenflex1.TextMatrix(flex1.Row,1)=Trim(.Fields("商品名称")) If.Fields("规格")<>""Thenflex1.TextMatrix(flex1.Row,2)=Trim(.Fields("规格")) If.Fields("单位")<>""Thenflex1.TextMatrix(flex1.Row,3)=Trim(.Fields("单位")) flex1.TextMatrix(flex1.Row,5)=.Fields("成本价") EndWith flex1.Col=4 DataGrid2.Visible=False'DataGrid2不可见 txtEdit.Text="" txtEdit.SetFocus EndIf IfKeyCode=vbKe