DataGridTextBoxColumn.EndEdit Method ()


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Use BaseTrue

Ends an edit operation on the DataGridColumnStyle.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

protected void EndEdit()

To edit the value of a cell, call the DataRow object's BeginEdit before changing the value. You must invoke the AcceptChanges method on both the DataRow and DataTable objects before the change is committed.

The following example invokes the EndEdit method before editing a column's value.

Private Sub EditGrid()
    ' Get the current DataGridColumnStyle through the CurrentCell.
    Dim dgCol As DataGridColumnStyle
    Dim colNum As Integer
    Dim rowNum As Integer
    Dim dataTable1 As DataTable

    With dataGrid1.CurrentCell
        colNum = .ColumnNumber
        rowNum = .RowNumber    
    End With
    dgCol = dataGrid1.TableStyles(0).GridColumnStyles(ColNum)
    ' Invoke the BeginEdit method.

    If dataGrid1.BeginEdit(dgCol, rowNum) Then
        ' Edit row value.
        dataTable1 = dataSet1.Tables(dataGrid1.DataMember)
        Dim myRow As DataRow
        myRow = dataTable1.Rows(rowNum)
        myRow(colNum) = edit1.Text
        dataGrid1.EndEdit(dgcol, rowNum, False)
        Console.WriteLine("BeginEdit failed.")
    End If
End Sub

.NET Framework
Available since 1.1
Return to top