从另一个窗体调用工具栏按钮单击
在 VB6 中,我需要知道如何在另一个窗体上调用按钮单击事件。另一个表单部分很简单,但如何将单击事件传递给“单击”工具栏上的右键的正确方法是真正的问题。
这是主窗体上的通风口 - 我需要将单击事件案例称为“Copyfrom”。
MainForm
Public Sub tbrMain_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Index
Case ToolBarItem.tbPrint
'(some code)
Case ToolBarItem.tbSave
'(some code)
Case ToolBarItem.tbCopyFrom
'(some code)
Case ToolBarItem.tbNEW
'(etc)
我尝试过
Mainform.tbrMain_ButtonClick()
,甚至尝试传递索引号和密钥 - 没有骰子。
In VB6 I need to know how to call a button click event on anther form. The another form part is easy but how to pass the click event the proper method to "click" the right button on the toolbar is the real issue.
Here is the vent on the main form - i need to call the click event case "Copyfrom".
MainForm
Public Sub tbrMain_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Index
Case ToolBarItem.tbPrint
'(some code)
Case ToolBarItem.tbSave
'(some code)
Case ToolBarItem.tbCopyFrom
'(some code)
Case ToolBarItem.tbNEW
'(etc)
I tried
Mainform.tbrMain_ButtonClick()
and even tried passing the index number and key - no dice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事件处理程序期望接收对实际工具栏按钮的引用,因此您必须传递工具栏按钮本身,而不是它的
Caption
或Key
,例如:或者,使用
Call
语句:如果您在工具栏按钮上设置了
Key
属性,则可以使用所需按钮的 Key
属性代替 (1):The event handler is expecting to receive a reference to an actual toolbar button, so you have to pass the toolbar button itself, not it's
Caption
orKey
, e.g.:Or, using the
Call
statement:If you set the
Key
properties on your toolbar buttons, you can use theKey
property of the desired button in place of the (1):Private Sub Toolbar1_ButtonMenuClick(ByVal ButtonMenu As MSComctlLib.ButtonMenu)
如果 ButtonMenu.Key = "A" 那么
消息框“Button-1”
ElseIf ButtonMenu.Key = "B" 然后
消息框“按钮-2”
ElseIf ButtonMenu.Key = "C" 然后
消息框“按钮-3”
ElseIf ButtonMenu.Key = "D" 然后
消息框“按钮-4”
ElseIf ButtonMenu.Key = "E" 然后
消息框“按钮-5”
结束如果
结束子
Private Sub Toolbar1_ButtonMenuClick(ByVal ButtonMenu As MSComctlLib.ButtonMenu)
If ButtonMenu.Key = "A" Then
MsgBox "Button-1"
ElseIf ButtonMenu.Key = "B" Then
MsgBox "Button -2"
ElseIf ButtonMenu.Key = "C" Then
MsgBox "Button -3"
ElseIf ButtonMenu.Key = "D" Then
MsgBox "Button -4"
ElseIf ButtonMenu.Key = "E" Then
MsgBox "Button -5"
End If
End Sub