DataGridView.IsCurrentCellDirty 속성

정의

현재 셀에 커밋되지 않은 변경 내용이 있는지 여부를 나타내는 값을 가져옵니다.

public:
 property bool IsCurrentCellDirty { bool get(); };
[System.ComponentModel.Browsable(false)]
public bool IsCurrentCellDirty { get; }
[<System.ComponentModel.Browsable(false)>]
member this.IsCurrentCellDirty : bool
Public ReadOnly Property IsCurrentCellDirty As Boolean

속성 값

현재 셀에 커밋되지 않은 변경 내용이 있으면 true이고, 그렇지 않으면 false입니다.

특성

예제

다음 코드 예제를 사용 하 여 IsCurrentCellDirty 는 셀 값을 커밋 하 고 이벤트에 대 CurrentCellDirtyStateChanged 한 처리기에서 이벤트를 발생 CellValueChanged 할지 여부를 결정 하는 속성입니다. 이 코드 예제는 방법: Windows Forms DataGridView 컨트롤의 단추 열에서 단추 사용 안 함에서 제공하는 더 큰 예제의 일부입니다.

// This event handler manually raises the CellValueChanged event
// by calling the CommitEdit method.
void dataGridView1_CurrentCellDirtyStateChanged(object sender,
    EventArgs e)
{
    if (dataGridView1.IsCurrentCellDirty)
    {
        dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit);
    }
}

// If a check box cell is clicked, this event handler disables  
// or enables the button in the same row as the clicked cell.
public void dataGridView1_CellValueChanged(object sender,
    DataGridViewCellEventArgs e)
{
    if (dataGridView1.Columns[e.ColumnIndex].Name == "CheckBoxes")
    {
        DataGridViewDisableButtonCell buttonCell =
            (DataGridViewDisableButtonCell)dataGridView1.
            Rows[e.RowIndex].Cells["Buttons"];

        DataGridViewCheckBoxCell checkCell =
            (DataGridViewCheckBoxCell)dataGridView1.
            Rows[e.RowIndex].Cells["CheckBoxes"];
        buttonCell.Enabled = !(Boolean)checkCell.Value;

        dataGridView1.Invalidate();
    }
}
' This event handler manually raises the CellValueChanged event
' by calling the CommitEdit method.
Sub dataGridView1_CurrentCellDirtyStateChanged( _
    ByVal sender As Object, ByVal e As EventArgs) _
    Handles dataGridView1.CurrentCellDirtyStateChanged

    If dataGridView1.IsCurrentCellDirty Then
        dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit)
    End If
End Sub

' If a check box cell is clicked, this event handler disables  
' or enables the button in the same row as the clicked cell.
Public Sub dataGridView1_CellValueChanged(ByVal sender As Object, _
    ByVal e As DataGridViewCellEventArgs) _
    Handles dataGridView1.CellValueChanged

    If dataGridView1.Columns(e.ColumnIndex).Name = "CheckBoxes" Then
        Dim buttonCell As DataGridViewDisableButtonCell = _
            CType(dataGridView1.Rows(e.RowIndex).Cells("Buttons"), _
            DataGridViewDisableButtonCell)

        Dim checkCell As DataGridViewCheckBoxCell = _
            CType(dataGridView1.Rows(e.RowIndex).Cells("CheckBoxes"), _
            DataGridViewCheckBoxCell)
        buttonCell.Enabled = Not CType(checkCell.Value, [Boolean])

        dataGridView1.Invalidate()
    End If
End Sub

설명

DataGridView 데이터에 바인딩되지 않으면 사용자가 다른 셀로 이동할 때 셀 편집이 커밋된 것으로 간주됩니다.

행 머리글이 표시되면 커밋되지 않은 변경 내용이 있는 셀이 포함된 행의 머리글에 연필 문자 모양이 표시됩니다.

true 이고 현재 셀이 편집 컨트롤을 호스트하는 경우 IsCurrentCellDirty 속성을 통해 EditingControl 검색할 수 있습니다.

적용 대상

추가 정보