Visualizzazione dei risultati da 1 a 5 su 5
  1. #1

    [vb.net] collegare evento due forms

    Data la form una con un combobox cp1 nella form1 contenente l'elenco dei clienti di un negozio(c1 viene riempito usando la sub riempic1() ) e la form2 che consente di inserire i campi di un nuovo cliente come faccio ad aggiornare c1 nella form1 dopo che è stato premuto il tasto "inserisciCliente" nella form2

  2. #2
    Potresti fare che alla form1_Activated richiami la funzione che ti crea l'elenco dei clienti. In modo da avere l'elenco sempre aggiornato sia quando aggiungi un cliente che quando lo elimini e poi ritorni al Form1.

  3. #3
    no perche perdo l'inizializzazione dei campi già inseriti manualmente dall'utente collegato al programma

  4. #4
    per ritorni intendi apri la form1 nuavamente? o forse non ho capito io? mi fai un esempio?

  5. #5

    bastava trattare il componente come un oggetto

    bastava trattare il componente come un oggetto ....Faccio un esempio con un bottone e due form




    ' attenzione sono 2 form



    Public Class Form1
    Inherits System.Windows.Forms.Form

    #Region " Windows Form Designer generated code "

    Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    '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

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.
    'Do not modify it using the code editor.
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.Button1 = New System.Windows.Forms.Button
    Me.TextBox1 = New System.Windows.Forms.TextBox
    Me.SuspendLayout()
    '
    'Button1
    '
    Me.Button1.Location = New System.Drawing.Point(120, 16)
    Me.Button1.Name = "Button1"
    Me.Button1.Size = New System.Drawing.Size(104, 96)
    Me.Button1.TabIndex = 0
    Me.Button1.Text = "Button1"
    '
    'TextBox1
    '
    Me.TextBox1.Location = New System.Drawing.Point(224, 160)
    Me.TextBox1.Name = "TextBox1"
    Me.TextBox1.TabIndex = 1
    Me.TextBox1.Text = "TextBox1"
    '
    'Form1
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(292, 273)
    Me.Controls.Add(Me.TextBox1)
    Me.Controls.Add(Me.Button1)
    Me.Name = "Form1"
    Me.Text = "Form1"
    Me.ResumeLayout(False)

    End Sub

    #End Region

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
    Dim frm As New Form2


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim frm As New Form2

    frm.Button1.Text = "ddddddddddd"
    frm.Show()
    frm.bb = Button1
    End Sub
    End Class






    Public Class Form2
    Inherits System.Windows.Forms.Form

    #Region " Windows Form Designer generated code "

    Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    '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

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.
    'Do not modify it using the code editor.
    Friend WithEvents Button1 As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.Button1 = New System.Windows.Forms.Button
    Me.SuspendLayout()
    '
    'Button1
    '
    Me.Button1.Location = New System.Drawing.Point(120, 136)
    Me.Button1.Name = "Button1"
    Me.Button1.TabIndex = 0
    Me.Button1.Text = "Button1"
    '
    'Form2
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(292, 273)
    Me.Controls.Add(Me.Button1)
    Me.Name = "Form2"
    Me.Text = "Form2"
    Me.ResumeLayout(False)

    End Sub

    #End Region
    Dim c As New Form
    Public bb As Button
    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    bb.Text = "alfa"
    End Sub
    End Class

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.