Private Sub Listbox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles Listbox1.SelectedIndexChanged
ComboBox1.Items.Clear()
Select Case Listbox1.SelectedIndex.ToString
Case "0"
Me.CenterToScreen()
ComboBox1.Items.Add(" ")
ComboBox1.Items.Add(" ")
ComboBox1.Items.Add(" ")
ComboBox1.SelectedIndex = 0
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList
Label2.Text = " "
Label3.Text = " "
Label4.Text = " "
PictureBox4.ImageLocation = " "
PictureBox5.ImageLocation = " "
PictureBox6.ImageLocation = " "
โค้ดปุ่ม ADD ของฟอร์มที่ 1
Code (VB.NET)
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Me.DialogResult = DialogResult.OK
End Sub
นี่คือโค้ดปุ่มที่ให้ User คลิกเพื่อแอดข้อมูลจากฟอร์ม 1 มา ฟอร์ม 2 นี้นะครับ
Code (VB.NET)
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim frmForm3 As New Form2
frmForm3.ShowDialog()
If frmForm3.DialogResult = Windows.Forms.DialogResult.OK Then
TextBox1.Text = frmForm3.Listbox1.Text
TextBox2.Text = frmForm3.ComboBox1.Text
End If
End Sub