繁体   English   中英

Access-VBA:如何在TreeView-NodeClick中检测鼠标键

[英]Access-VBA: How do I detect the mouse-key in a TreeView-NodeClick

我有一个带有Click-Event的TreeView。 由于我需要通过右键单击实现面向节点的dropdown-context-menu,因此如果按下了鼠标右键,我该如何检入现有的Click-Event。 到目前为止,我的Methode看起来像这样:

Private Sub tvwKategorien_NodeClick(ByVal Node As Object)
    Dim sBez1 As String
    Dim sLangtext As String
    Dim sWKZ As String
    Dim sSprache As String
    Dim dPreis As Double
    If ((Node Is Nothing) = False) Then
        If mbParseNodeKeyAndTag(Node) Then
            Set moSelectedNode = Node
            If msKategorie = frmArtikelgruppenRoot Then
                    Me.pagKategorie.Visible = False
                    Me.pagArtikel.Visible = False
                    Me.pagPicture.Visible = False
                    Me.pagCrosslinks.Visible = False
                    Me.SubArtikel.Visible = False
                    Me.txtKategorie = msKategorie
                    Me.txtBezeichnung = msBezeichnung
                    Me.PicArtikel.Visible = False
                    Call mEnableSubArtikel
           Else
                If mbIstNodeKategorie(moSelectedNode) Then
                    Me.pagKategorie.Visible = True
                    Me.pagArtikel.Visible = False
                    Me.pagPicture.Visible = False
                    Me.pagCrosslinks.Visible = False
                    Me.SubArtikel.Visible = True
                    Me.txtKategorie = msKategorie
                    Me.txtBezeichnung = msBezeichnung
                    Me.PicArtikel.Visible = False
                    If Node.Child Is Nothing Then
                        Dim oNodeParam As Node
                        Set oNodeParam = Node
                        Call mReadUntergruppen(oNodeParam, oNodeParam.Key, gnCInt(gsParameter(oNodeParam.Text, "Gruppenebene")) + 1)
                    End If
                    Call mEnableSubArtikel
                    Dim rs As Recordset
                    Set rs = Me.SubArtikel.Form.Recordset
                    If Not rs Is Nothing Then
                        Call mReadArtikel(Node, Node.Key, gnCInt(gsParameter(Node.Text, "Gruppenebene")) + 1)
                        Node.Expanded = True
                    Else
                        Node.Expanded = False
                    End If
                Else
                    Me.pagKategorie.Visible = False
                    Me.pagArtikel.Visible = True
                    Me.pagPicture.Visible = True
                    Me.pagCrosslinks.Visible = True
                    Me.SubArtikel.Visible = False
                    Me.txtArtNr = msBezeichnung
                    Me.txtArt = msBezeichnung & " " & gvntLookup("Matchcode", "KHKArtikel", "Artikelnummer='" & msBezeichnung & "' AND Mandant=" & gnManId, "")
                    cbBild.Value = "ITPWeb_"
                    Call mInitPicture
                    nil = gITPWebGetArtPreis(msBezeichnung, 0, sWKZ, dPreis, cbShop.Value)
                    Me.txtArtPreis = dPreis
                    Me.txtArtWkz = sWKZ
                    If gvntNull2Arg(cboSprache, "") = "" Then
                        sSprache = "W" & gvntManProperty(22)
                    Else
                        sSprache = CStr(cboSprache)
                    End If
                    nil = gITPWebGetArtBez(sSprache, msBezeichnung, sBez1, sLangtext)
                    Me.txtArtBezeichnung = sBez1
                    Me.txtArtLangtext = sLangtext
                    msAktuelleKategorie = Split(Node.Key, ";")(0)
                    Me.cboBonusprodukt.Locked = False
                    sSplit = Split(Node.Key, ";")
                    Me.cboBonusprodukt.Value = gvntLookup("BonusProduct", "ITPWebKategorienArtikel", "Artikelnummer=" & gsStr2Sql(msBezeichnung) & " AND Mandant=" & gnManId & " and Kategorie = " & gsStr2Sql(msAktuelleKategorie) & " and Pos = " & sSplit(getArrayLenght(sSplit)), 0)
                    Me.cboBonusprodukt.AllowValueListEdits = False
                    Me.txtBonuspunkte = gvntNull2Arg(gvntLookup("Bonuspunkte", "ITPWebKategorienArtikel", "Artikelnummer=" & gsStr2Sql(msBezeichnung) & " AND Mandant=" & gnManId & " and Kategorie = " & gsStr2Sql(msAktuelleKategorie) & " and Pos = " & sSplit(getArrayLenght(sSplit)), 0), 0)
                    Me.chkOrderable = gvntLookup("USER_ITPWebOrderable", "KHKArtikel", "Artikelnummer=" & gsStr2Sql(msBezeichnung) & " AND Mandant=" & gnManId, -1)
                    Me.chkShopActive = gvntLookup("USER_ITPWebShopActive", "KHKArtikel", "Artikelnummer=" & gsStr2Sql(msBezeichnung) & " AND Mandant=" & gnManId, -1)
                    Me.chkPricePush = gvntLookup("USER_ITPWebPricePush", "KHKArtikel", "Artikelnummer=" & gsStr2Sql(msBezeichnung) & " AND Mandant=" & gnManId, 0)
                    Call mEnableSubCrosslinks
                End If
            End If
        End If
    End If
    tvwKategorien_NodeClick_Error:
End Sub

我正在使用VBA在访问文档中工作:(

您必须对树tvwKategorien使用MouseDown事件并标记一些模块变量,以便稍后在NodeClick检查它

将其放在模块的开头,但在Option字符串之后

private MouseButton as Integer

添加MouseDown事件

Private Sub tvwKategorien_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Long, ByVal y As Long)
     MouseButton =Button
End Sub

然后使用这种条件来检测现有NodeClick事件中的右键单击

If MouseButton = acRightButton Then ' right

If MouseButton = acLeftButton Then ' left

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM