dtProductList โหลดข้อมุลจากออบเจ็กต์ dr
With com
.Parameters.Clear()
.Parameters.Add("@BranchID", SqlDbType.NVarChar).Value = CStr(cboBranch.SelectedValue)
.CommandText = sqlShowProductList
.CommandType = CommandType.Text
.Connection = Conn
dr = .ExecuteReader()
If dr.HasRows Then
dtProductList = New DataTable
dtProductList.Load(dr)
dgvProductList.DataSource = dtProductList
With dgvProductList
.DataSource = dtProductList
Dim cbcUnitName As DataGridViewComboBoxColumn
cbcUnitName = New DataGridViewComboBoxColumn
cbcUnitName.Name = "NewUnitName"
cbcUnitName.HeaderText = "หน่วยใหม่"
cbcUnitName.DataSource = dtUnit
cbcUnitName.ValueMember = "UnitID"
cbcUnitName.DisplayMember = "UnitName"
cbcUnitName.DisplayIndex = 6
.Columns.Add(cbcUnitName)
Dim cbcQuantityPerUnit As DataGridViewTextBoxColumn
cbcQuantityPerUnit = New DataGridViewTextBoxColumn
cbcQuantityPerUnit.Name = "QuantityPerUnit"
'cbcQuantityPerUnit.HeaderText = "Header_QuantityPerUnit"
cbcQuantityPerUnit.DisplayIndex = 7
.Columns.Add(cbcQuantityPerUnit)
End With
FormatDgvProductList()
cmdSave.Enabled = True
Else
cmdSave.Enabled = False
dgvProductList.DataSource = Nothing
End If
End With
end Sub