Public Class Form1
Dim WithEvents _frmSearch As New frmSearch
Private Sub Form1_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
If Not IsNothing(_frmSearch) Then
If Not _frmSearch.IsDisposed Then
_frmSearch.ShowDialog()
Else
Dim _frmSearch As New frmSearch
_frmSearch.ShowDialog()
End If
Else
_frmSearch = New frmSearch
_frmSearch.ShowDialog()
End If
End Sub
Private Sub _frmSearchEmp_TextHasChanged() Handles _frmSearch.TextHasChanged
Me.TextBox1.Text = _frmSearch.DataGV.CurrentRow.Cells(1).Value.ToString.Trim()
End Sub
End Class
****************** frmSearch ใส่ Code ลงไป
Public Class frmSearch
Event TextHasChanged()
Private Sub frmSearch_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ดึงข้อมูลลง DataGridview
End Sub
Private Sub DataGV_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGV.DoubleClick
If Me.DataGV.Rows.Count <= 1 Then Exit Sub
If IsDBNull(Me.DataGV.CurrentRow.Cells(0).Value) Then Exit Sub
RaiseEvent TextHasChanged()
Me.Close()
End Sub