我有一个名为 "FrmClientesEdicion "的表单,其中有一个邮政编码字段,我试图打开邮政编码文件,并将第二个表单中选择的信息从数据网格返回到第一个表单。发生的事情是,到目前为止,信息没有传递给我,而是打开了一个新的实例的形式 "FrmClientesEdicion",帮助?
从 "FrmClientesEdicion "中的一个按钮打开邮政编码表格 "FrmCodigosPosAr",其中有一行。
Dim f As New FrmCodigosPosAr
f.ShowDialog()
在表格中搜索:"FrmCodigosPosAr",选择一行,然后再把数据(如代码,姓名)传给第一行。"FrmClientesEdicion "中的这行。
Try
Dim F As New FrmClienteEdicion
With F
.TxtCPOCLI.Text = DG.CurrentRow.Cells(0).Value.ToString ' The code
.TxtPOBCLI.Text = DG.CurrentRow.Cells(1).Value.ToString ' The name city
.TxtPROCLI.Text = DG.CurrentRow.Cells(2).Value.ToString ' The state
End With
Catch ex As Exception
MsgBox("Verifique: " & ex.Message.ToString, MsgBoxStyle.Critical)
End Try
Me.Close()
这第二点不工作打开一个新的实例,但不`......再次感谢注:第一个表单仍然打开,当我打开第二个表单时从未关闭它!图片。
我回答自己的情况下,有人需要它
在form2 (FremCodigosPosAr)中。
Public Class FrmCodigosPosAr
Inherits System.Windows.Forms.Form
Public myCaller As FrmClienteEdicion
在表格1中,(例如,在按钮中调用表格2(FrmCodigosPosAr))。
Dim myform As FrmCodigosPosAr
Private Sub BtnBuscaCP_Click(sender As Object, e As EventArgs) Handles BtnBuscaCP.Click
If myform Is Nothing Then
myform = New FrmCodigosPosAr
myform.myCaller = Me
End If
myform.Show()
结束子
在表格2(FrmCodigosPosAr)中,将数据传递给表格1(FrmClientesEdicion)
Try
If Not myCaller Is Nothing Then
myCaller.Text = Now.ToLongTimeString
myCaller.TxtCPOCLI.Text = DG.CurrentRow.Cells(0).Value.ToString
myCaller.TxtPOBCLI.Text = DG.CurrentRow.Cells(1).Value.ToString
myCaller.TxtPROCLI.Text = DG.CurrentRow.Cells(2).Value.ToString
End If
Catch ex As Exception
MsgBox("Verifique: " & ex.Message.ToString, MsgBoxStyle.Critical)
End Try
Me.Close()