EVENTO CHECKEDCHANGED DATAGRIDVIEW
Olá amigos.
como faço para pegar o evento CheckedChanged em datagridview?
neste grid eu totalizo itens checados, porem ao marcar ou desmarcar o checkbox nada acontece... somente qdo checo o checkbox seguinte que a soma é efetuada.
Programei os eventos abaixo.... mas em todos eles mesmo apos mudar o valor do chec, na função soma o valor do check não muda
Private Sub DGV_CP_CellEndEdit(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV_CP.CellEndEdit
DGV_CP.Refresh()
Lbl_Vlr_Total_Sel.Text = Soma_DGV_Check()
End Sub
Private Sub DGV_CP_CellContentClick(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV_CP.CellContentClick
Lbl_Vlr_Total_Sel.Text = Soma_DGV_Check()
End Sub
Private Sub DGV_CP_CellValueChanged(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV_CP.CellValueChanged
If e.ColumnIndex = 0 Then
Lbl_Vlr_Total_Sel.Text = Soma_DGV_Check()
End If
End Sub
Private Sub DGV_CP_SelectionChanged(sender As System.Object, e As System.EventArgs) Handles DGV_CP.SelectionChanged
Lbl_Vlr_Total_Sel.Text = Soma_DGV_Check()
End Sub
Private Function Soma_DGV_Check() As Decimal
Dim Vlsoma As Decimal
For i As Integer = 0 To DGV_CP.RowCount - 1
[ô] If DGV_CP.Item(IcolCH, i).Value = True Then
If Convert.ToBoolean(DGV_CP.Rows(i).Cells(0).Value) Then
Vlsoma = Vlsoma + CDec(DGV_CP.Item(IcolVL, i).Value)
End If
Next
Return Vlsoma
end sub
como faço para pegar o evento CheckedChanged em datagridview?
neste grid eu totalizo itens checados, porem ao marcar ou desmarcar o checkbox nada acontece... somente qdo checo o checkbox seguinte que a soma é efetuada.
Programei os eventos abaixo.... mas em todos eles mesmo apos mudar o valor do chec, na função soma o valor do check não muda
Private Sub DGV_CP_CellEndEdit(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV_CP.CellEndEdit
DGV_CP.Refresh()
Lbl_Vlr_Total_Sel.Text = Soma_DGV_Check()
End Sub
Private Sub DGV_CP_CellContentClick(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV_CP.CellContentClick
Lbl_Vlr_Total_Sel.Text = Soma_DGV_Check()
End Sub
Private Sub DGV_CP_CellValueChanged(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV_CP.CellValueChanged
If e.ColumnIndex = 0 Then
Lbl_Vlr_Total_Sel.Text = Soma_DGV_Check()
End If
End Sub
Private Sub DGV_CP_SelectionChanged(sender As System.Object, e As System.EventArgs) Handles DGV_CP.SelectionChanged
Lbl_Vlr_Total_Sel.Text = Soma_DGV_Check()
End Sub
Private Function Soma_DGV_Check() As Decimal
Dim Vlsoma As Decimal
For i As Integer = 0 To DGV_CP.RowCount - 1
[ô] If DGV_CP.Item(IcolCH, i).Value = True Then
If Convert.ToBoolean(DGV_CP.Rows(i).Cells(0).Value) Then
Vlsoma = Vlsoma + CDec(DGV_CP.Item(IcolVL, i).Value)
End If
Next
Return Vlsoma
end sub
Veja se isso te ajuda
Private Sub DataGridView1_CellMouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseUp
If TypeOf DataGridView1.CurrentCell Is DataGridViewCheckBoxCell Then
DataGridView1.EndEdit()
Dim cellVal As Boolean = DirectCast(DataGridView1.CurrentCell.Value, Boolean)
If cellVal Then
MsgBox([Ô]Current cell is Checked[Ô])
Else
MsgBox([Ô]Current cell is Unchecked[Ô])
End If
End If
End Sub
Fonte: http://www.vbforums.com/showthread.php?t=429234&highlight=datagridview+checkbox
Abraço
Private Sub DataGridView1_CellMouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseUp
If TypeOf DataGridView1.CurrentCell Is DataGridViewCheckBoxCell Then
DataGridView1.EndEdit()
Dim cellVal As Boolean = DirectCast(DataGridView1.CurrentCell.Value, Boolean)
If cellVal Then
MsgBox([Ô]Current cell is Checked[Ô])
Else
MsgBox([Ô]Current cell is Unchecked[Ô])
End If
End If
End Sub
Fonte: http://www.vbforums.com/showthread.php?t=429234&highlight=datagridview+checkbox
Abraço
matou!!!!
Valeu Mitsueda... Brigadão
Valeu Mitsueda... Brigadão
Tópico encerrado , respostas não são mais permitidas