|
 |
|
ถามเรื่องการคลิก DataGridView1 ให้ไปแสดงรายละเอียดที่ DataGridView2 ค่ะ |
|
 |
|
|
 |
 |
|
ถามเรื่องการคลิก DataGridView1 ให้ไปแสดงรายละเอียดที่ DataGridView2 ค่ะ
ที่ทำสามารถคลิกเเล้วเเสดงค่าได้ค่ะ ในการคลิกครั้งเเรกเเสดงข้อมูลได้ตรงตาม Header
เเต่คลิกรอบ2 ค่าที่เเสดงไม่ตรงตาม Header ค่ะ
ตามรูปคะ(คลิกรอบที่1)

คลิกรอบที่2

Code Refresh_Grid1
Code (VB.NET)
Private Sub Refresh_Grid()
Dim d_adap As SqlDataAdapter
Dim d_set As DataSet
d_set = New DataSet
d_adap = New SqlDataAdapter("select Care_ID,Care_Date,Emp_Fname,Emp_Lname,Care_Status " & _
"from Care_Service , Employee " & _
"Where Emp_ID = Emp_No", sqlConnection)
d_adap.Fill(d_set, "Care_Service")
DataGridView1.DataSource = d_set.Tables("Care_Service")
DataGridView1.Columns("Care_ID").DisplayIndex = 0
DataGridView1.Columns("Care_Date").DisplayIndex = 1
DataGridView1.Columns("Emp_Fname").DisplayIndex = 2
DataGridView1.Columns("Emp_Lname").DisplayIndex = 3
DataGridView1.Columns("Care_Status").DisplayIndex = 4
DataGridView1.Columns(0).HeaderText = "รหัสการฝาก"
DataGridView1.Columns(1).HeaderText = "วันที่ฝาก"
DataGridView1.Columns(2).HeaderText = "ชื่อพนักงานรับฝาก"
DataGridView1.Columns(3).HeaderText = "นามสกุลพนักงานรับฝาก"
DataGridView1.Columns(4).HeaderText = "สถานะการฝาก"
DataGridView1.Columns(0).Width = 120
DataGridView1.Columns(1).Width = 120
DataGridView1.Columns(2).Width = 140
DataGridView1.Columns(3).Width = 160
DataGridView1.Columns(4).Visible = False
End Sub
code อันนี้คลิกที่ DataridView1 เเล้วให้ไปเเสดงที่ DataridView2
Code (VB.NET)
With DataGridView1
tb_CareID.Text = .Rows.Item(e.RowIndex).Cells(0).Value.ToString()
dt_CareDate.Text = .Rows.Item(e.RowIndex).Cells(1).Value.ToString()
lb_empFname.Text = .Rows.Item(e.RowIndex).Cells(2).Value.ToString()
lb_empLname.Text = .Rows.Item(e.RowIndex).Cells(3).Value.ToString()
If (.Rows.Item(e.RowIndex).Cells(4).Value.ToString() = "CA") Then
CareService.Checked = True
Else
ReturnDog.Checked = True
End If
End With
Dim d_adap As SqlDataAdapter
Dim d_set As DataSet
d_set = New DataSet
d_adap = New SqlDataAdapter("select Cdog_ID,Cdog_Name,Cdog_Sex,Cdog_Color,Breed_Name,Size_Name," & _
"Care_ID " & _
"from Customer_Dog,Dog_Breed,Price_Rate,Care_Service,Care_Detail " & _
"Where Cdog_ID = Cdog_No and Dog_Breed_ID = Cdog_Breed_No and Care_ID = Care_No " & _
"and Size_ID = Size_No and Care_No = '" & tb_CareID.Text & "'", sqlConnection)
d_adap.Fill(d_set, "Care_Detail")
DataGridView2.Columns(0).DataPropertyName = "Cdog_ID"
DataGridView2.Columns(1).DataPropertyName = "Cdog_Name"
DataGridView2.Columns(2).DataPropertyName = "Cdog_Sex"
DataGridView2.Columns(3).DataPropertyName = "Cdog_Color"
DataGridView2.Columns(4).DataPropertyName = "Breed_Name"
DataGridView2.Columns(5).DataPropertyName = "Size_Name"
DataGridView2.DataSource = d_set.Tables("Care_Detail")
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2010-01-29 15:36:00 |
By :
numsom |
View :
1335 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 01
|