直接投射不起作用

时间:2014-04-14 21:11:24

标签: vb.net

我正在尝试为动态创建的buttong添加句柄。这是我的直播(我缩短了代码):

    Private Sub handleItemButton(ByVal sender As Object, ByVal e As EventArgs)

    Dim btnItemButton As NewItemButton = DirectCast(sender, NewItemButton)

    Dim StrItemName As String = TextBox1.Text
    Dim strQty As String = "1"
    Dim dblQty As Double = CDbl(TextBox2.Text)
    Dim dblPrice As Double = CDbl(TextBox3.Text)
    Dim dblTotal As Double = dblPrice * dblQty


    MessageBox.Show(StrItemName)


End Sub

这是我的经纪人:

    Private Sub btnAddNewItem_Click(sender As Object, e As EventArgs) Handles btnAddNewItem.Click

    Dim btnItemButton As New NewItemButton

    AddHandler btnItemButton.Click, AddressOf handleItemButton

    flpItem.Controls.Add(btnItemButton)



End Sub

添加了按钮,但处理程序无法正常工作。我点击新创建的按钮,没有任何反应。

0 个答案:

没有答案