[英]how to go back (move back) to a form with a value
我在查找窗口中遇到了严重问题,请帮助解决此问题。
看到我的表单打开的步骤
打开第一个表单(从仪表板)
Dim ObjOrder As New OrderFormFrm ObjOrder.USER = USER ObjOrder.Show()
接下来,我必须基于文本框事件打开一个弹出窗口。
Private Sub txtCustCode_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles txtCustCode.MouseClick Dim PopUpCustomer As New searchCustomerfrm PopUpCustomer.ShowDialog() End Sub
我必须使用基于gridview行单击事件的值返回到Orderform
Private Sub DGVCustomer_CellContentDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGVCustomer.CellContentDoubleClick OrderFormFrm.txtCustCode.Text = Val(DGVCustomer.Item(1, e.RowIndex).Value)` Me.Close() End Sub
问题是,当我从'OrderFormFrm'
(项目属性设置-启动表单)启动项目表单时,我从Orderform的文本框中获得了价值,而从仪表板启动项目'OrderFormFrm'
没有得到。
我需要在订单表单文本框'txtCustCode'
显示值'DGVCustomer.Item(1, e.RowIndex).Value'
'txtCustCode'
请帮忙解决这个问题
您可以在searchCustomerfrm
表单上创建一个共享函数,该函数返回该表单期望的值:
Public Shared Function GetCustomer()
Dim PopUpCustomer As New searchCustomerfrm
If PopUpCustomer.ShowDialog() = DialogResult.OK Then
Return Val(PopUpCustomer.DGVCustomer.Item(1, PopUpCustomer.DGVCustomer.CurrentRow.Index).Value)
Else
Return Nothing
End If
End Function
在DGVCustomer_CellContentDoubleClick
以下内容:
Private Sub DGVCustomer_CellContentDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGVCustomer.CellContentDoubleClick
Me.DialogResult = DialogResult.OK
End Sub
要调用searchCustomerfrm
从OrderFormFrm
你也会有这样的代码:
txtCustCode.Text = searchCustomerfrm.GetCustomer
除非我错过了什么,否则您需要通过实例名称而不是类型来调用原始表单。
Private Sub DGVCustomer_CellContentDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGVCustomer.CellContentDoubleClick
ObjOrder.txtCustCode.Text = Val(DGVCustomer.Item(1, e.RowIndex).Value)
Me.Close()
End Sub
将一个名为sendingForm的公共属性添加到您的searchCustomerFrm类中
Public Class searchCustomerFrm
Public sendingForm As OrderFormFrm
然后在创建新表单时将该属性设置为发送表单
Private Sub txtCustCode_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles txtCustCode.MouseClick
Dim PopUpCustomer As New searchCustomerfrm
PopUpCustomer.sendingForm = Me
PopUpCustomer.ShowDialog()
End Sub
最后,设置发送表单的textbox属性
Private Sub DGVCustomer_CellContentDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGVCustomer.CellContentDoubleClick
sendingForm.txtCustCode.Text = Val(dgvCustomer.Item(1, e.RowIndex).Value)
Me.Close()
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.