我在运行时创建了一个带有几个按钮和一个组合框的窗体。如何捕获运行时对象上的事件
dim f as new form
(等等等等)
然后按钮acceptDescription和rejectDescription都设置...
然后组合框descriptionCombo设置...
然后...
AddHandler acceptDescription.Click, AddressOf handleAcceptedDescription
AddHandler rejectDescription.Click, AddressOf handleRejectedDescription
然后我有这两种方法来捕捉点击事件...但无法弄清楚如何引用其他运行时生成d控件。 (如果被接受,则为组合框,如果被拒绝则表格)
Private Sub handleAcceptedDescription(ByVal sender As System.Object, ByVal e As System.EventArgs)
'stub
'will need to reference the chosen combobox value here
dim acceptedDescription as string = descriptionCombo.selectedValue .tostring
End Sub
Private Sub handleRejectedDescription(ByVal sender As System.Object, ByVal e As System.EventArgs)
'I want to close the runtime created form here, but can't reference it
f.close()
'and return user to main form
Me.Focus()
End Sub
这应该工作 - 但我想,它必须能够没有宣布更多的全局变量。 谢谢。 – m42 2009-03-05 16:53:54