이 위대한 포럼을 처음 사용했습니다. 목록 상자에서 마우스 오른쪽 버튼을 클릭하여 메뉴를 표시하려고합니다. 현재 간단한 메시지 상자를 보여주는 오른쪽 클릭 메뉴를 구현하려고합니다.팝업 메뉴에서 마우스 오른쪽 버튼을 클릭하면 나타나는 메뉴
제 문제는 목록 상자가 최대화 된 팝업 폼에 있다는 것입니다. 이제는 목록 상자를 오른쪽 클릭 할 때 오른쪽 클릭 메뉴를 볼 수 있지만 메뉴 옵션 중 하나를 클릭 할 때 아무것도 성공하지 않습니다 (함수로 이동하지 않는 것 같습니다). 나는 또한 함수에 중단 점을 넣었지만 팁을주지 않았다.
양식 팝업 옵션을 아니오로 설정하면 오른쪽 클릭 메뉴가 완벽하게 작동한다는 점이 중요합니다 (옵션 중 하나를 클릭하면 해당 메시지가 표시됨). 나는 다음과 같은 VBA 코드 실행 해요
:
Private Sub Song_List_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
' Call the SetUpContextMenu function to ensure it is setup with most current context
' Note: This really only needs to be setup once for this example since nothing is
' changed contextually here, but it could be further expanded to accomplish this
SetUpContextMenu
' See if the right mouse button was clicked
If Button = acRightButton Then
'DoCmd.CancelEvent
CommandBars("MyListControlContextMenu").ShowPopup
End If
End Sub
은 "SetUpContextMenu"하위 설정 :
Public Sub SetUpContextMenu()
' Note: This requires a reference to Microsoft Office Object Library
Dim combo As CommandBarControl
' Since it may have been defined in the past, it should be deleted,
' or if it has not been defined in the past, the error should be ignored
On Error Resume Next
CommandBars("MyListControlContextMenu").Delete
On Error GoTo 0
' Make this menu a popup menu
With CommandBars.Add(Name:="MyListControlContextMenu", Position:=msoBarPopup)
' Provide the user the ability to input text using the msoControlEdit type
Set combo = .Controls.Add(Type:=msoControlEdit)
combo.Caption = "Lookup Text:" ' Add a label the user will see
combo.OnAction = "=getText()" ' Add the name of a function to call
' Provide the user the ability to click a menu option to execute a function
Set combo = .Controls.Add(Type:=msoControlButton)
combo.BeginGroup = True ' Add a line to separate above group
combo.Caption = "Lookup Details" ' Add label the user will see
combo.OnAction = "=LookupDetailsFunction()" ' Add the name of a function to call
' Provide the user the ability to click a menu option to execute a function
Set combo = .Controls.Add(Type:=msoControlButton)
combo.Caption = "Delete Record" ' Add a label the user will see
combo.OnAction = "=DeleteRecordFunction()" ' Add the name of the function to call"
combo.SetFocus
combo.Visible = True
End With
End Sub
을
이 내 목록 상자에 마우스 업 이벤트 핸들러
클릭시 다른 메신저 상자를 표시하는 3 가지 기능을 모두 설정하십시오.
Public Function getText() As String
getText = CommandBars("MyListControlContextMenu").Controls(" Lookup Text:").Text
' You could optionally do something with this text here,
' such as pass it into another function ...
MsgBox "You typed the following text into the menu: " & getText
End Function
Public Function LookupDetailsFunction() As String
LookupDetailsFunction = "Hello World!"
MsgBox LookupDetailsFunction, vbInformation, "Notice!"
End Function
Public Function DeleteRecordFunction()
' If Not IsNull(Forms!MyFormName.Controls("Song_List").Colu mn(0)) Then
MsgBox "Record Deleted"
' End If
End Function
shourtcut 메뉴 모음 설정이 "MyListControlContextMenu"로 설정되었습니다. 문제는 메뉴에 팝업 폼과 관련된 제약이 있습니다 ... – skakooli2