预览加载中,请您耐心等待几秒...
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改成txteditPublicrs1AsNewADODB.Recordset,rs2AsNewADODB.Recordset'定义数据集对象DimiAsInteger,jAsIntegerSubEditKeyCode(MSHFlexGridAsControl,EdtAsControl,KeyCodeAsInteger,ShiftAsInteger)'标准编辑控件处理。SelectCaseKeyCodeCase27'ESC:隐藏焦点并将其返回MSFlexGridEdt.Visible=FalseMSHFlexGrid.SetFocusCase13'ENTER将焦点返回MSFlexGrid。MSHFlexGrid.SetFocusDoEventsIfMSHFlexGrid.Col<MSHFlexGrid.Cols-1ThenMSHFlexGrid.Col=MSHFlexGrid.Col+1ElseIfMSHFlexGrid.Col=MSHFlexGrid.Cols-1ThenMSHFlexGrid.Row=MSHFlexGrid.Row+1MSHFlexGrid.Col=1EndIfEndIfCase38'向上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),"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)<>""Andflex1.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=bValflex1.Enabled=bValFrame1.Enabled=bValEndSubPrivateSubDataGrid2_KeyDown(KeyCodeAsInteger,ShiftAsInteger)IfKeyCode=vbKeyReturnThenWithAdodc2.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("成本价")EndWithflex1.Col=4DataGrid2.Visible=False'DataGrid2不可见txtEdit.Text=""txtEdit.SetFocusEndIfIfKeyCode=vbKeyEscapeThen'按ESC键DataGrid2不可见DataGrid2.Visible=False'txtEdit.SetFocus'tx