我有一个名为“ 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()
第二点无法打开新实例,但不能... 再次感谢 注意:第一个窗体仍处于打开状态,当我打开第二个窗体时切勿关闭它! 图片:
答案 0 :(得分:0)
如果有人需要我会自己回答
在form2(FrmCodigosPosAr)
Public Class FrmCodigosPosAr
Inherits System.Windows.Forms.Form
Public myCaller As FrmClienteEdicion
在表单1中,(例如在一个按钮中调用form2(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)的形式将数据传递到Form1(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()