อันนี้โค้ด ตรงฟอร์มโหลดครับ ข้อมูลขึ้นจากตาราง doctor ปกติครับ
Code (VB.NET)
Dim cs = From c In dbDokmai.doctors
Select c.doc_id, c.doc_name
With cbb_doc
.BeginUpdate()
.DisplayMember = "doc_name"
.ValueMember = "doc_id"
.DataSource = cs.ToList()
.EndUpdate
End With
ส่วนอันนี้ตรง dgv_care_CellMouseUp ครับ
Code (VB.NET)
Private Sub dgv_care_CellMouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles dgv_care.CellMouseUp
If e.RowIndex = -1 Then Exit Sub
With dgv_care
txt_care_id.Text = .Rows.Item(e.RowIndex).Cells(0).Value.ToString()
txt_sick.Text = .Rows.Item(e.RowIndex).Cells(1).Value.ToString()
txt_detail.Text = .Rows.Item(e.RowIndex).Cells(2).Value.ToString()
txt_pama.Text = .Rows.Item(e.RowIndex).Cells(3).Value.ToString()
dtp_care.Text = .Rows.Item(e.RowIndex).Cells(4).Value.ToString()
txt_cus_id.Text = .Rows.Item(e.RowIndex).Cells(5).Value.ToString()
cbb_doc.Text = .Rows.Item(e.RowIndex).Cells(6).Value.ToString() ' บรรทัดที่ให้ไปแสดงใน cbb ครับ
txt_care_id.Focus()
txt_care_id.SelectAll()
End With
txt_sick.ReadOnly = True
txt_detail.ReadOnly = True
txt_pama.ReadOnly = True
End Sub
Tag : .NET, Ms SQL Server 2012, VS 2012 (.NET 4.x)
Dim cs = From c In dbDokmai.doctors
Select c.doc_id, c.doc_name
With cbb_doc
.BeginUpdate()
.DisplayMember = "doc_name"
.ValueMember = "doc_id"
.DataSource = cs.ToList()
.EndUpdate
End With