 |
|
เมื่อคลิกที่ checkbox ที่อยู่ใน datagridview จะให้ Active ทันที่ที่คลิก อะคับ |
|
 |
|
|
 |
 |
|
ใช้ event CellValueChanged จะได้ DataGridViewCellEventArgs e
ซึ่งสามารถเป็น property e.ColumnIndex กับ e.RowIndex เพื่ออ้างอิง value ใน cell
หรือจะแปลง object ของ cell นั้นกลับเป็น DataGridViewCheckBoxCell แล้วอ้างอิงจาก
DataGridViewCheckBoxCell ก็ได้ ซึ่งจะได้ value และ index
เอาไป update database ได้เหมือนกัน
|
 |
 |
 |
 |
Date :
2010-07-31 17:59:08 |
By :
tungman |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ในการ update นั้น update แบบธรรมดาหรือเปล่าคับ หรือไม่ธรรมดา
|
 |
 |
 |
 |
Date :
2010-07-31 21:56:39 |
By :
adunafah |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันมีแบบไม่ธรรมดาด้วยเหรอ
|
 |
 |
 |
 |
Date :
2010-07-31 22:09:03 |
By :
tungman |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าต้องการที่จะเลือกทั้งหมดโดย คลิกที่ปุ่มเลือกทั้งหมดต้องเขียนไงอะคับ พอมีตัวอย่างไหมคับ
|
 |
 |
 |
 |
Date :
2010-08-01 09:23:45 |
By :
adunafah |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
Private Sub CheckAllButton_Click(ByVal sender As Object, ByVal e As System.Windows.Forms.EventArgs) Handles CheckAllButton.Click
For Each row As DataGridViewRow In dgvBorrower.Rows
Dim chk As DataGridViewCheckBoxCell = DirectCast(row.Cells(7), DataGridViewCheckBoxCell)
chk.Value = True
Next
End Sub
|
 |
 |
 |
 |
Date :
2010-08-01 09:47:04 |
By :
tungman |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
update ยังไม่ได้เลยคับท่าน (ตายแน่ๆ)
|
 |
 |
 |
 |
Date :
2010-08-02 11:25:52 |
By :
adunafah |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
Private Sub dgvBorrower_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvBorrower.CellValueChanged
If e.ColumnIndex = 7 Then
Dim chk As DataGridViewCheckBoxCell = DirectCast(dgvBorrower.Rows(e.RowIndex).Cells(7), DataGridViewCheckBoxCell)
dgvBorrower.Rows(e.RowIndex).Cells(8).Value = If((chk.Value = True), "Yes", "No")
End If
End Sub
|
 |
 |
 |
 |
Date :
2010-08-02 11:47:38 |
By :
tungman |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มัน error ว่า Expression expected. อะคับตรง If((chk.Value = True), "Yes", "No")
|
 |
 |
 |
 |
Date :
2010-08-02 21:38:50 |
By :
adunafah |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แก้ต่อเองดิทำ ทำให้ดูขนาดนี้แล้ว
Expression expected. สงสัยจะเกี่ยวกับ type ของสอง object ที่เอามาเปรียบเทียบ
|
 |
 |
 |
 |
Date :
2010-08-02 23:29:28 |
By :
tungman |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2010-08-02 23:48:58 |
By :
adunafah |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอถามหน่อยได้มั๊ยคะ คือ datagridColumnCheckbox
อ่ะคะมี code สร้างมั๊ยคะ คือทำโปรเจคอล้วต้องใช้เหมือนกันค่ะ
แต่ว่าทำแบบ dynamic checkbox ค่ะ ต้อง fix ว่าให้มันขึ้นเฉพาะ row
ที่ต้องการ ตอนนี้ยังทำไม่ได้เลยค่ะ ช่วยหน่อยค่ะ
|
 |
 |
 |
 |
Date :
2010-08-25 02:43:16 |
By :
nui |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าไม่ได้จริงๆ ก็คงต้องเป็นอย่างนั้นค่ะ
แต่แสดงออกมามันดูไม่ค่อย work ค่ะ
อาจารย์อยากให้ออกมาดูดีหน่อย
|
 |
 |
 |
 |
Date :
2010-08-25 11:16:53 |
By :
nui |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|