DataGridTextBoxColumn::Edit Method (CurrencyManager^, Int32, Rectangle, Boolean, String^, Boolean)
.NET Framework (current version)
Prepares a cell for editing.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
public protected: virtual void Edit( CurrencyManager^ source, int rowNum, Rectangle bounds, bool readOnly, String^ displayText, bool cellIsVisible ) override
Parameters
- source
-
Type:
System.Windows.Forms::CurrencyManager^
The CurrencyManager of the DataGrid control the column belongs to.
- rowNum
-
Type:
System::Int32
The row number in this column being edited.
- bounds
-
Type:
System.Drawing::Rectangle
The bounding Rectangle in which the control is to be sited.
- readOnly
-
Type:
System::Boolean
A value indicating whether the column is a read-only. true if the value is read-only; otherwise, false.
- displayText
-
Type:
System::String^
The text to display in the control.
- cellIsVisible
-
Type:
System::Boolean
A value indicating whether the cell is visible. true if the cell is visible; otherwise, false.
The following example uses the Edit method to change the text of a clicked cell in the DataGrid control.
public ref class MyGridColumn: public DataGridTextBoxColumn { public: void EditCol( CurrencyManager^ cm, int rowNum, Rectangle cellRect, bool readOnly, String^ myString, bool isVisible ) { this->Edit( cm, rowNum, cellRect, readOnly, myString, isVisible ); } }; public ref class Form1: public Form { protected: DataGrid^ dataGrid1; DataSet^ myDataSet; private: void dataGrid1_MouseDown( Object^ sender, MouseEventArgs^ e ) { // Use the HitTest method to get a HitTestInfo object. DataGrid::HitTestInfo ^ hi; DataGrid^ grid = dynamic_cast<DataGrid^>(sender); hi = grid->HitTest( e->X, e->Y ); // Test if the clicked area was a cell. if ( hi->Type == DataGrid::HitTestType::Cell ) { // If it's a cell, get the GridTable and CurrencyManager of the // clicked table. DataGridTableStyle^ dgt = dataGrid1->TableStyles[ 0 ]; CurrencyManager^ cm = dynamic_cast<CurrencyManager^>(this->BindingContext[ myDataSet->Tables[ dgt->MappingName ] ]); // Get the Rectangle of the clicked cell. Rectangle cellRect = grid->GetCellBounds( hi->Row, hi->Column ); // Get the clicked DataGridTextBoxColumn. MyGridColumn^ gridCol = dynamic_cast<MyGridColumn^>(dgt->GridColumnStyles[ hi->Column ]); // Edit the value. gridCol->EditCol( cm, hi->Row, cellRect, false, "New Text", true ); } } };
.NET Framework
Available since 1.1
Available since 1.1
Show: