DataGridTextBoxColumn.EndEdit Metod

Definition

Avslutar en redigeringsåtgärd på DataGridColumnStyle.

protected:
 void EndEdit();
protected void EndEdit();
member this.EndEdit : unit -> unit
Protected Sub EndEdit ()

Exempel

I följande exempel anropas metoden innan du redigerar EndEdit en kolumns värde.

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.BeginEdit
        myRow(colNum) = edit1.Text
        myRow.AcceptChanges
        dataTable1.AcceptChanges
        Console.WriteLine("Edited?")
        dataGrid1.EndEdit(dgcol, rowNum, False)
    Else
        Console.WriteLine("BeginEdit failed.")
    End If
End Sub

Kommentarer

Om du vill redigera värdet för en cell anropar du DataRow objektets BeginEdit innan du ändrar värdet. Du måste anropa AcceptChanges metoden på både objekten DataRow och DataTable innan ändringen har checkats in.

Gäller för