我在運行時創建了一個帶有幾個按鈕和一個組合框的窗體。如何捕獲運行時對象上的事件
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