共用方式為


DataGrid.EndEdit(DataGridColumnStyle, Int32, Boolean) 方法

定義

要求結束 DataGrid 控制項的編輯作業。

public:
 virtual bool EndEdit(System::Windows::Forms::DataGridColumnStyle ^ gridColumn, int rowNumber, bool shouldAbort);
public bool EndEdit (System.Windows.Forms.DataGridColumnStyle gridColumn, int rowNumber, bool shouldAbort);
abstract member EndEdit : System.Windows.Forms.DataGridColumnStyle * int * bool -> bool
override this.EndEdit : System.Windows.Forms.DataGridColumnStyle * int * bool -> bool
Public Function EndEdit (gridColumn As DataGridColumnStyle, rowNumber As Integer, shouldAbort As Boolean) As Boolean

參數

gridColumn
DataGridColumnStyle

DataGridColumnStyle,將停止編輯作業。

rowNumber
Int32

要停止編輯作業的資料列編號。

shouldAbort
Boolean

如果應該停止目前作業,則設定為 true

傳回

Boolean

如果編輯作業停止,則為 true,否則為 false

實作

範例

下列程式碼範例會使用 BeginEditEndEdit 方法來編輯 控制項所顯示 System.Windows.Forms.DataGrid 方格中的值。

void EditValue()
{
   int rowtoedit = 1;
   CurrencyManager^ myCurrencyManager = dynamic_cast<CurrencyManager^>(this->BindingContext[ ds->Tables[ "Suppliers" ] ]);
   myCurrencyManager->Position = rowtoedit;
   DataGridColumnStyle^ dgc = dataGrid1->TableStyles[ 0 ]->GridColumnStyles[ 0 ];
   dataGrid1->BeginEdit( dgc, rowtoedit );
   
   // Insert code to edit the value.
   dataGrid1->EndEdit( dgc, rowtoedit, false );
}
private void EditValue()
{ 
   int rowtoedit = 1;
   CurrencyManager myCurrencyManager = 
   (CurrencyManager)this.BindingContext[ds.Tables["Suppliers"]];
   myCurrencyManager.Position=rowtoedit;
   DataGridColumnStyle dgc = dataGrid1.TableStyles[0].GridColumnStyles[0];
   dataGrid1.BeginEdit(dgc, rowtoedit);
   // Insert code to edit the value.
   dataGrid1.EndEdit(dgc, rowtoedit, false);
}
Private Sub EditValue()
   Dim rowtoedit As Integer = 1
   Dim myCurrencyManager As CurrencyManager = _
   CType(Me.BindingContext(ds.Tables("Suppliers")), CurrencyManager)
   myCurrencyManager.Position = rowtoedit
   Dim dgc As DataGridColumnStyle = _
   dataGrid1.TableStyles(0).GridColumnStyles(0)
   dataGrid1.BeginEdit(dgc, rowtoedit)
   ' Insert code to edit the value.
   dataGrid1.EndEdit(dgc, rowtoedit, False)
End Sub

備註

如果使用者未編輯 (在儲存格) 輸入,則方法 EndEditfalse 傳回 。

適用於

另請參閱