Controls [vb.net] DataGridView의 CellValidating 이벤트를 활용한 셀 변경 값, 변경 이전 값을 비교하여 이…
페이지 정보

본문
    Private Sub DataGridView_CellValidating(sender As Object, e As DataGridViewCellValidatingEventArgs) Handles DataGridView1.CellValidating,
                                                                                                            DataGridView2.CellValidating,
                                                                                                            DataGridView4.CellValidating,
                                                                                                            DataGridView5.CellValidating,
                                                                                                            DataGridView7.CellValidating
        If e.ColumnIndex < 0 Then Return
        If e.RowIndex < 0 Then Return
        Dim DGV As DataGridView = CType(sender, DataGridView)
        If DGV.Rows.Count = 0 Then Return
        Dim key As String = DGV.Columns(e.ColumnIndex).Name
        If key = "ck" Then DGV.EndEdit() : Return
        Dim URL As String, PostData As String, T As String
        Dim R As DataGridViewRow = DGV.Rows(e.RowIndex)
        Dim cell As DataGridViewTextBoxCell = R.Cells(key)
        Dim oldValue As String, newValue As String
        If IsDBNull(cell.Value) Then Return
        oldValue = cell.Value
        newValue = e.FormattedValue
        If oldValue = newValue Then Return
        If key = "note" Then
            '// 원하는 작업
        Else
            e.Cancel = True
            If cell.IsInEditMode Then DGV.EndEdit()
            cell.Value = oldValue
        End If
    End Sub
- 이전글[vb.net] TextBox 기본 문구/안내 문구(Default Text) 설정 22.09.20
 - 다음글[vb.net] SaveFileDialog 예제 21.06.04
 
댓글목록
등록된 댓글이 없습니다.



