如何处理按钮单击甚至从.dll

时间:2016-02-03 13:33:07

标签: vb.net forms dll autodesk-inventor

有人可以指导我如何实际工作吗?目前它给了我关于WithEvents的错误 - 尽管它简化了它显示的形式 - 但我不知道这实际意味着什么。这是一个工具箱,我只是为了让用户更好地与我的其他代码进行交互。

我需要的只是自定义视觉/内容的形式,然后是在我的应用程序中完成的代码(没有可视化编辑功能)。

这是我需要使用接口/部分类/继承的情况,还是只需稍微调整一下即可轻松实现?

(在visual studio表单设计器中创建的表单,然后更改为类库。在Autodesk Inventor“规则”环境中编写的应用程序代码)

谢谢!

申请代码:

AddReference "C:\Users\Documents\Visual Studio 2013\Projects\WindowsApplication1\WindowsApplication1\bin\Release\SectionSymToolBox.dll" 

Imports System.Windows.Forms

Public Class SectionSymRule
'Public dlg As New System.Windows.Forms.For
Public Shared ToolBox As New SectionSymToolBox.SectionSymToolBox

Dim WithEvents EClass As New EventClass

Sub Main()
    ToolBox.Show()
End Sub

End Class

表格代码:

Public Class SectionSymToolBox

Private Sub Main()
End Sub

Public Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
    'Swap Symbols
End Sub

Public Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    'Flip Symbol
End Sub

Public Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    'Flip Text
End Sub

Public Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
    '<
End Sub

Public Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
'>
End Sub

End Class

1 个答案:

答案 0 :(得分:0)

这是你在找什么?

AddHandler ToolBox.Button1.Click, AddressOf HandlerMethodHere

其中HandlerMethod是一种与Button1具有相同签名的方法,例如:

Private Sub HandleButton1Click(sender As Object, e As EventArgs)
'Code here
End Sub

显然,将Button1替换为按钮的名称。