Private Sub DataGridView1_CellDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellDoubleClick
With Edit_User
.setEdit_UserName(DataGridView1.Rows(e.RowIndex).Cells("USER_NAME").Value)
.setEdit_FirstName(DataGridView1.Rows(e.RowIndex).Cells("FIRST_NAME").Value)
.setEdit_LastName(DataGridView1.Rows(e.RowIndex).Cells("LAST_NAME").Value)
.setEdit_Edit_DEPARTMENT(DataGridView1.Rows(e.RowIndex).Cells("DEPARTMENT").Value) 'ส่งค่าฟิลด์ รหัสสินค้า ใน DataGridView ไป Form2
.Show() 'เปิด Form 2
End With
ผมใช้โค้ดตัวนี้ส่งค่าไป
Code (VB.NET)
Private Edit_UserName As String
Private Edit_FirstName As String
Private Edit_LastName As String
Private Edit_DEPARTMENT As String
'เซตรหัส
Public Sub setEdit_UserName(ByVal UserName As String)
Edit_UserName = UserName
End Sub
Public Sub setEdit_FirstName(ByVal FirstName As String)
Edit_FirstName = FirstName
End Sub
Public Sub setEdit_LastName(ByVal LastName As String)
Edit_LastName = LastName
End Sub
Public Sub setEdit_Edit_DEPARTMENT(ByVal DEPARTMENT As String)
Edit_DEPARTMENT = DEPARTMENT
End Sub
Private Sub Edit_User_Load(sender As Object, e As EventArgs) Handles MyBase.Load
TextBox1.Text = Edit_UserName
TextBox2.Text = Edit_FirstName
TextBox3.Text = Edit_LastName
ComboBox2.Text = Edit_DEPARTMENT