Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Elnata COsta

Passar valores entre formulários! E carregar o XML!

Recommended Posts

Bom pessoal tenho o seguinte código:

 

Form_pega_os_dados:

Imports System
Imports System.IO
Imports System.Xml
Imports System.Data

Public Class Form_VAProfile

 Inherits System.Windows.Forms.Form

    Dim DefinicoesServer As DataSet
    Dim cm As CurrencyManager

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()
        DefinicoesServer = New DataSet("VaConn")
        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
#End Region


 Private Sub Vincular()
        'vinculamos os dados do documento xml aos controles
        txtMail.DataBindings.Add("Text", DefinicoesServer, "VaConn.Email")
        txtPilotname.DataBindings.Add("Text", DefinicoesServer, "VaConn.PilotName")
        txtServer.DataBindings.Add("Text", DefinicoesServer, "VaConn.Server")
        txtUserId.DataBindings.Add("Text", DefinicoesServer, "VaConn.UserId")
        txtUserPass.DataBindings.Add("Text", DefinicoesServer, "VaConn.Password")
        txtDataBase.DataBindings.Add("Text", DefinicoesServer, "VaConn.DataBase")
        txtTablePrefix.DataBindings.Add("Text", DefinicoesServer, "VaConn.TablePrefix")


        'vinculamos o currencymanager
        cm = CType(Me.BindingContext(DefinicoesServer, "VaConn"), CurrencyManager)

    End Sub




 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            DefinicoesServer.ReadXml("cfg.xml")
            Vincular()
            CalcularPosicao()
        Catch ex As Exception
            MsgBox(ex.Message())
            Me.Close()
        End Try
    End Sub



                              'BOTÃO ADICIONAR VALORES NO XML!!!!
 Private Sub tbIncluir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbIncluir.Click
        cm.AddNew()
        CalcularPosicao()
        Dim frmtemp As Form_Login = New Form_Login
        frmtemp.frm1 = Me
        frmtemp.Show()
    End Sub





                      'BOTÃO PARA GRAVAR OS VALORES NO XML!!!!
  Private Sub btnGravar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGravar.Click
        cm.EndCurrentEdit()
        DefinicoesServer.WriteXml("cfg.xml")
        Dim frmtemp As Form_Login = New Form_Login
        frmtemp.frm1 = Me
        frmtemp.Show()
        Me.Close()
        Form_Login.Close()
        Form_Login.Show()
    End Sub
End Class

 

E o Form_Login que deveria receber os valores:

 

Option Strict On
Imports System.Data
Imports System.IO
Imports System.Drawing.Color
Imports MySql.Data
Imports MySql.Data.MySqlClient
Imports MySql.Web
Imports System.Net
Imports System




Public Class Form_Login


  

    Public frm1 As Form_VAProfile


    Friend WriteOnly Property text_ServerLogin As String
        Set(ByVal value As String)
            txtServerLogin.Text = value
        End Set
    End Property

    Private Sub Form_Login_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Timer_Conn_Internet.Start()

        txtServerLogin.Text = My.Forms.Form_VAProfile.txtServer.Text
     

      

    End Sub

 Friend WriteOnly Property text_Box2 As String
        Set(ByVal value As String)
            txtServerLogin.Text = value
        End Set
    End Property
End Class

 

Porém o Form_Login não recebe o valor quando eu clico em adicionar, o que há de errado no código pessoal??

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.