欢迎来到天天文库
浏览记录
ID:15334462
大小:56.50 KB
页数:7页
时间:2018-08-02
《vb数据库编程中mshflexgrid控件用法详解》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、VB数据库编程中MSHFlexGrid控件用法详解添加MSHFlexGrid将Name改成flex1添加text将name改成txteditPublicrs1AsNewADODB.Recordset,rs2AsNewADODB.Recordset'定义数据集对象DimiAsInteger,jAsIntegerSubEditKeyCode(MSHFlexGridAsControl,EdtAsControl,KeyCodeAsInteger,ShiftAsInteger)'标准编辑控件处理。SelectCaseKeyCodeCase27'ESC:隐藏焦点并将
2、其返回MSFlexGridEdt.Visible=FalseMSHFlexGrid.SetFocusCase13'ENTER将焦点返回MSFlexGrid。MSHFlexGrid.SetFocusDoEventsIfMSHFlexGrid.Col3、dIfCase38'向上MSHFlexGrid.SetFocusDoEventsIfMSFlexGrid.Row>MSFlexGrid.FixedRowsThenMSFlexGrid.Row=MSFlexGrid.Row-1EndIfEndSelectEndSubSubview_DP()Ifflex1.Col=4Orflex1.Col=5Orflex1.Col=6Then'格式化Flex1表的第7列、第8列、第9列、第11列flex1.TextMatrix(flex1.Row,5)=Format(flex1.TextMatrix(flex1.Row,5)4、,"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")EndIfDimA,BAsSingle'声明单精度浮点型变量OnErrorResumeNextFori=1Toflex1.Rows-1Ifflex1.TextMatrix(i,1)<>""Andfl5、ex1.TextMatrix(i,4)<>""Andflex1.TextMatrix(i,6)<>""ThenA=Val(flex1.TextMatrix(i,6))+A'求合计金额B=Val(flex1.TextMatrix(i,4))+B'求合计数量EndIfNextilblCount=BlblSum=Format(A,"0.00")'格式化合计金额EndSubSubSetButtons(bValAsBoolean)cmdRegister.Enabled=NotbValcmdSave.Enabled=bValcmdCancel.Enabled=bVa6、lflex1.Enabled=bValFrame1.Enabled=bValEndSubPrivateSubDataGrid2_KeyDown(KeyCodeAsInteger,ShiftAsInteger)IfKeyCode=vbKeyReturnThenWithAdodc2.Recordset'赋值给flex1表格If.Fields("商品名称")<>""Thenflex1.TextMatrix(flex1.Row,1)=Trim(.Fields("商品名称"))If.Fields("规格")<>""Thenflex1.TextMatrix(flex7、1.Row,2)=Trim(.Fields("规格"))If.Fields("单位")<>""Thenflex1.TextMatrix(flex1.Row,3)=Trim(.Fields("单位"))flex1.TextMatrix(flex1.Row,5)=.Fields("成本价")EndWithflex1.Col=4DataGrid2.Visible=False'DataGrid2不可见txtEdit.Text=""txtEdit.SetFocusEndIfIfKeyCode=vbKeyEscapeThen'按ESC键DataGrid2不可见Dat8、aGrid2.Visible=False'txtEdit.SetFocus'tx
3、dIfCase38'向上MSHFlexGrid.SetFocusDoEventsIfMSFlexGrid.Row>MSFlexGrid.FixedRowsThenMSFlexGrid.Row=MSFlexGrid.Row-1EndIfEndSelectEndSubSubview_DP()Ifflex1.Col=4Orflex1.Col=5Orflex1.Col=6Then'格式化Flex1表的第7列、第8列、第9列、第11列flex1.TextMatrix(flex1.Row,5)=Format(flex1.TextMatrix(flex1.Row,5)
4、,"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")EndIfDimA,BAsSingle'声明单精度浮点型变量OnErrorResumeNextFori=1Toflex1.Rows-1Ifflex1.TextMatrix(i,1)<>""Andfl
5、ex1.TextMatrix(i,4)<>""Andflex1.TextMatrix(i,6)<>""ThenA=Val(flex1.TextMatrix(i,6))+A'求合计金额B=Val(flex1.TextMatrix(i,4))+B'求合计数量EndIfNextilblCount=BlblSum=Format(A,"0.00")'格式化合计金额EndSubSubSetButtons(bValAsBoolean)cmdRegister.Enabled=NotbValcmdSave.Enabled=bValcmdCancel.Enabled=bVa
6、lflex1.Enabled=bValFrame1.Enabled=bValEndSubPrivateSubDataGrid2_KeyDown(KeyCodeAsInteger,ShiftAsInteger)IfKeyCode=vbKeyReturnThenWithAdodc2.Recordset'赋值给flex1表格If.Fields("商品名称")<>""Thenflex1.TextMatrix(flex1.Row,1)=Trim(.Fields("商品名称"))If.Fields("规格")<>""Thenflex1.TextMatrix(flex
7、1.Row,2)=Trim(.Fields("规格"))If.Fields("单位")<>""Thenflex1.TextMatrix(flex1.Row,3)=Trim(.Fields("单位"))flex1.TextMatrix(flex1.Row,5)=.Fields("成本价")EndWithflex1.Col=4DataGrid2.Visible=False'DataGrid2不可见txtEdit.Text=""txtEdit.SetFocusEndIfIfKeyCode=vbKeyEscapeThen'按ESC键DataGrid2不可见Dat
8、aGrid2.Visible=False'txtEdit.SetFocus'tx
此文档下载收益归作者所有