注册 登录
编程论坛 VB6论坛

求助在VsFlexGrid控件上实现三级联动菜单,并注册单击事件。

扑腾 发布于 2023-10-30 20:18, 1708 次点击
想用VB+VsFlexGrid+Access做一个出入库管理程序。卡在输入环节一直没有进展,想要图中的输入方式和效果,求大神帮帮忙!谢谢!
补充:以附件中Excel文件的“商品目录”和“库存”两个表做数据源
只有本站会员才能查看附件,请 登录

只有本站会员才能查看附件,请 登录


[此贴子已经被作者于2023-10-30 20:25编辑过]

10 回复
#2
yuma2023-10-30 20:37
你妹,你这个程序看上去高端。

#3
扑腾2023-10-30 22:06
或者哪位有现成的工程附件发一个也行,谢谢!
#4
扑腾2023-10-30 22:12
回复 2楼 yuma
大神棒棒忙,卡在这里了快半年了,谢谢!
#5
扑腾2023-10-31 13:01
用vba能实现VsFlexGrid控件上的三级联动菜单和单击事件注册,但移植到vb6.0上就行不通了,菜单能显示,但单击无效果,各路大神帮帮忙!
#6
牛掰2023-10-31 15:49
回复 5楼 扑腾
这个三级联动要用其它的方式来替代,比如你这个Excel就是用这种方式,请上传Excel附件
#7
扑腾2023-10-31 18:38
回复 6楼 牛掰
excel文件在附件中,正在琢磨老师以前的二级联动菜单的帖子
#8
扑腾2023-10-31 21:25
回复 6楼 牛掰
Excel表中的三级菜单代码如下:
Sub CreatMe() '生成左键树型菜单
    Dim d As Object, i&, j&, k, k2, t, a, l&, arr, x As Object
    Application.ScreenUpdating = False
    Set d = CreateObject("scripting.dictionary")
    arr = Sheets("货品资料").[B2].CurrentRegion
    For i = 2 To UBound(arr)
        If Not d.Exists(arr(i, 1)) Then Set d(arr(i, 1)) = CreateObject("scripting.dictionary")
        If Len(arr(i, 2)) Then d(arr(i, 1))(arr(i, 2)) = d(arr(i, 1))(arr(i, 2)) & "," & arr(i, 3) & " " & arr(i, 4) & " " & arr(i, 5)
    Next
    k = d.keys '一级分类
   On Error Resume Next
    ("树型菜单").Delete '删除可能存在的
    With ("树型菜单", msoBarPopup)
        For i = 0 To UBound(k)
            With .Controls.Add(Type:=IIf(d(k(i)).Count, msoControlPopup, msoControlButton))
                .Caption = k(i)
                .OnAction = IIf(d(k(i)).Count, "", "'显示在活动单元格 """ & k(i) & """'")
                .BeginGroup = True '分组显示
                k2 = d(k(i)).keys '二级分类
                t = d(k(i)).items '三级分类,每个三级分类用逗号隔开
                For j = 0 To UBound(k2)
                    a = Split(t(j), ",")
                    With .Controls.Add(Type:=IIf(Len(t(j)) > UBound(a), msoControlPopup, msoControlButton))
                        .Caption = k2(j)
                        .OnAction = IIf(Len(t(j)) > UBound(a), "", "'显示在活动单元格 """ & k(i) & "," & k2(j) & """'")
                        For l = 1 To UBound(a)
                            If Len(a(l)) Then
                                pms = Split(a(l)):                        ''''''''''''''分割显示:品名,条码,单位
                                pm = pms(0):                                        '   品名
                                pm1 = pms(1):                                       '   条码
                                pm2 = pms(2)                                        '   单位
                                With .Controls.Add(Type:=msoControlButton)
                                    .BeginGroup = True
                                    .Caption = pm
                                    .OnAction = "'显示在活动单元格 """ & k(i) & "," & k2(j) & "," & pm & "," & pm1 & "," & pm2 & """'"
                                End With
                            End If
                        Next
                    End With
                Next
            End With
        Next
    End With
    Application.ScreenUpdating = True
End Sub

Sub 显示在活动单元格(s$)
    Dim a: a = Split(s, ",")
    ActiveCell.Resize(1, 5) = a
End Sub


移植到vb6.0的窗体中后,红色代码就不起作用了,点击菜单选项时数据无法写入表单控件中。
#9
扑腾2023-10-31 21:33
回复 6楼 牛掰
在vba窗体+VSFlexGrid控件上也能使用,移植到vb6.0就不行了



[此贴子已经被作者于2023-10-31 23:01编辑过]

#10
牛掰2023-11-02 13:07
回复 9楼 扑腾
你如果不会那样修改的话,你就换一个思路。我给你截图了三张图片,在每个单元格中的点击事件中写判断前一个单元格是否为空,如果不为空就填充下拉参数就行了
只有本站会员才能查看附件,请 登录
只有本站会员才能查看附件,请 登录
只有本站会员才能查看附件,请 登录
只有本站会员才能查看附件,请 登录


[此贴子已经被作者于2023-11-2 13:12编辑过]

#11
扑腾2023-11-03 12:00
回复 10楼 牛掰
谢谢回复,分级筛选不是最想要的效果,只能怪自己基础太薄了
1