1

谁能帮我这个?

我有一个名为“frmMainMenu”的表单,其中有一个面板。这是我的主菜单表格。![这是我的主菜单。][1]

我有这个用户控件,即“uscPOS”。

当我单击 F8 时,表单内的面板将成为用户控件的父级。像这样。

我想要发生的是当我从表单中单击“新发票”按钮时,用户控件中的文本框将被启用。我的表格中有这个代码

Public Class frmMainMenu
Private Sub rbiPOS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbiPOS.Click
    Try
        Dim bLoad As Boolean = False

        If UIPanel.HasChildren Then
            If Not TypeOf (UIPanel.Controls(0)) Is uscPOS Then
                UIPanel.Controls.Clear()
                bLoad = True
            End If
        Else
            bLoad = True
        End If

        If bLoad Then
            Dim f As New uscPOS
            f.Parent = UIPanel
            f.Dock = DockStyle.Fill
            f.Visible = True
        End If

        rbrPOS.Enabled = True
        rbrProducts.Enabled = True
        rbrDiscount.Enabled = True
        rbrExact.Enabled = True

        btnNewInvoice.Enabled = True
        btnCancel.Enabled = False
        btnSettle.Enabled = False
        btnAddtxt.Enabled = False
        btnDelete.Enabled = False
        btnDiscount.Enabled = False

        rbtSenior.Enabled = False
        rbtExact.Enabled = False

        txtAmountTendered.Enabled = False
        txtDiscount.Enabled = False
    Catch ex As Exception
        MsgBox(ex.Message, MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "rbiPOS_Click")
    End Try
End Sub

Private Sub btnNewInvoice_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewInvoice.Click
    Try
        btnNewInvoice.Enabled = False
        btnCancel.Enabled = True
        btnSettle.Enabled = True
        btnAddtxt.Enabled = True
        btnDelete.Enabled = True
        btnDiscount.Enabled = True

        rbtSenior.Enabled = False
        rbtExact.Enabled = False

        txtAmountTendered.Enabled = False
        txtDiscount.Enabled = False

        **'starting from this part
        Dim f As New uscPOS
        f.txtCustomerName.Enabled = True
        f.txtCustomerAddress.Enabled = True
        f.txtContactNo.Enabled = True
        f.txtSearchProductCode.Enabled = True
        'i tried to put message box here just to know if this part is happening but the messagebox is displayed
        MsgBox("I am able to go to this part of code.")
        f.pnecbxSearchProductName.Visible = True
        f.pnecbxSearchProductName.Enabled = True
        f.pnecbxSearchProductName.Dock = DockStyle.Bottom
        f.txtUnitPrice.Enabled = True
        f.txtQuantity.Enabled = True
        MsgBox("I am at the end of the code.")
        'to this part, is not happening.**

    Catch ex As Exception
        MsgBox(ex.Message, MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "btNNewInvoice_Click")
    End Try
End Sub
End Class

但我不明白为什么它没有在我的用户控件中启用我的文本框,没有错误或警告。任何人都可以启发我吗?因此,我无法继续我的项目。帮助将不胜感激。谢谢..

4

1 回答 1

0

您创建了用户控件,但从未将其添加到面板中。

UIPanel.controls.add(f) 'adds your control to the panel
于 2013-11-22T19:27:26.400 回答