任何人都可以帮我吗?
我有一个表格,即“frmMainMenu”,其中有一个面板。 这是我的主菜单表格。 ![这是我的主菜单。] [1]
我有这个UserControl即“uscPOS”。
当我点击F8时,表单内的面板将成为usercontrol的父级。 像这样。
我想要发生的是当我从表单中单击“新建发票”按钮时,将启用usercontrol中的文本框。我的表格中有这个代码
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
但我无法理解为什么它没有在我的usercontrol中启用我的文本框,没有错误或警告。任何人都可以用这个来启发我吗?因为这个原因,我不能继续我的项目。帮助将不胜感激。感谢..
答案 0 :(得分:0)
您可以创建用户控件,但不要将其添加到面板中。
UIPanel.controls.add(f) 'adds your control to the panel