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 返回。

适用于

另请参阅