2010-05-30 151 views

回答

3

感謝CodeFluff爲答案。我已經適應了VB.Net,並在關閉窗口時包含了一個提交。

Private EditCommited As Boolean 

Private Sub MainWindow_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Me.Closing 
    CommitEdit() 
End Sub 

Private Sub DataGrid1_CellEditEnding(ByVal sender As Object, ByVal e As System.Windows.Controls.DataGridCellEditEndingEventArgs) Handles DataGrid1.CellEditEnding 
    CommitEdit() 
End Sub 

Sub CommitEdit() 
    If Not EditCommited Then 
     EditCommited = True 
     DataGrid1.CommitEdit(DataGridEditingUnit.Row, True) 
     EditCommited = False 
    End If 
End Sub 
相關問題