单击业务员类别制作
Private Sub mnuSalerType_Click() '业务员类别
frmSMType.strSQL = "SELECT * FROM jxc_SMType" frmSMType.Show '显示“业务员类别”窗体End SubMSHFlexGrid控件设置列标题,名称,
右键这个控件,设置列标题
下面是添加控件需要的绑定列
mshflexgrid、datagrid有什么区别,都是只读的表格
不能用ADOmshflexgrid是新版本的,可以用ADO,而且还能做之类的,功能强,但非常复杂,datagrid 可以实现普通的表格,而且几乎不用编程,最简单,当然功能没有上一个强.
msflexgrid 是老版本的,不能用ADO
这个联动窗体的制作
Private Sub Form_Load()
Dim i As Integer, strSQL1 As String strSQL1 = "SELECT sl_id,sl_name FROM jxc_sales" '查询所有业务员 Set rs = QueryExt(strSQL1) '执行SQL语句 With Combo1(0) '添加业务员到组合框 .Clear i = 0 Do While Not rs.EOF .AddItem rs.Fields(1) '添加业务员名称 .ItemData(i) = rs.Fields(0) '保存业务员编号 i = i + 1 rs.MoveNext '处理下一记录 Loop End With rs.Close strSQL1 = "SELECT sup_id,sup_name FROM jxc_supp" '获取所有供应商 Set rs = QueryExt(strSQL1) With Combo1(1) .Clear i = 0 Do While Not rs.EOF .AddItem rs.Fields(1) '添加供应商名称到组合框 .ItemData(i) = rs.Fields(0) '保存供应商编号 i = i + 1 rs.MoveNext '处理下一记录 Loop End With rs.Close strSQL1 = "SELECT cn_id,cn_name FROM jxc_CommName" '获取药品名称 Set rs = QueryExt(strSQL1) '执行SQL语句 With Combo1(2) .Clear i = 0 Do While Not rs.EOF .AddItem rs.Fields(1) '添加药品名称 .ItemData(i) = rs.Fields(0) '保存药品编号 i = i + 1 rs.MoveNext '处理下一记录 Loop End With
111
Private Sub Combo1_Click(Index As Integer)
Dim strSQL1 As String If Index = 1 Then '供应商组合框 txtItem(2) = Combo1(1).ItemData(Combo1(1).ListIndex) ElseIf Index = 2 Then '药品名称组合框 txtItem(3) = Combo1(2).ItemData(Combo1(2).ListIndex) '药品编号 strSQL1 = "SELECT cn_inPrice FROM jxc_CommName WHERE cn_id= '" & Trim(txtItem(3).Text) & "'" Set rs = QueryExt(strSQL1) If Not rs.EOF Then txtItem(6) = rs.Fields(0) '填充进货单价 End If rs.Close End IfEnd Submsflexgrid控件
mshflex grid我用代码显示列标题为啥12列,我要设置13列的
Private Sub ShowData()
Dim i As Integer If strSQL = "" Then Exit Sub '若模块变量strSQL为空,则退出 Set rs = QueryExt(strSQL) '从参数strSQL中得到记录集 With OutGrid .Rows = 1 Do While Not rs.EOF '循环处理记录集中的数据 .Rows = .Rows + 1 '表格的下一行 For i = 1 To rs.Fields.Count '循环处理记录中的各列 If Not IsNull(Trim(rs.Fields(i - 1))) Then '若字段不为空 Select Case rs.Fields(i - 1).Type '判断字段的类型 Case adDBDate '日期型 .TextMatrix(.Rows - 1, i) = Format(rs.Fields(i - 1) & "", "yyyy-mm-dd") Case Else '其他类型 .TextMatrix(.Rows - 1, i) = rs.Fields(i - 1) & "" End Select End If Next i rs.MoveNext '处理下一记录 Loop End With rs.Close '关闭记录集End SubPrivate Sub ShowTitle() '显示Grid表头
Dim i As Integer With OutGrid .Cols = 12 '设置表格为12列 .TextMatrix(0, 1) = "销售订单编号" .TextMatrix(0, 2) = "日期" .TextMatrix(0, 3) = "业务员" .TextMatrix(0, 4) = "客户代码" .TextMatrix(0, 5) = "药品代码" .TextMatrix(0, 6) = "期号" .TextMatrix(0, 7) = "数量" .TextMatrix(0, 8) = "出货单价" .TextMatrix(0, 9) = "折扣" .TextMatrix(0, 10) = "总金额" .TextMatrix(0, 11) = "备注" .FixedRows = 1 '固定表头 For i = 0 To 10 '设置各列的对齐方式 .ColAlignment(i) = 0 Next .FillStyle = flexFillRepeat '表头项居中 .Col = 0 .Row = 0 .RowSel = 1 .ColSel = .Cols - 1 .CellAlignment = 4 .ColWidth(0) = 100 For i = 1 To 11 '设置单元大小 .ColWidth(i) = 1000 Next .ColWidth(2) = 2000 .Row = 1 End WithEnd Sub 3 resize 事件