DataGridColumnStyle.Edit Método

Definición

Prepara la celda para editar un valor.Prepares the cell for editing a value.

Sobrecargas

Edit(CurrencyManager, Int32, Rectangle, Boolean)

Prepara una celda para que pueda editarse.Prepares a cell for editing.

Edit(CurrencyManager, Int32, Rectangle, Boolean, String)

Prepara la celda para la edición con el CurrencyManager, el número de fila y los parámetros Rectangle especificados.Prepares the cell for editing using the specified CurrencyManager, row number, and Rectangle parameters.

Edit(CurrencyManager, Int32, Rectangle, Boolean, String, Boolean)

Cuando se reemplaza en una clase derivada, prepara una celda para su edición.When overridden in a deriving class, prepares a cell for editing.

Edit(CurrencyManager, Int32, Rectangle, Boolean)

Prepara una celda para que pueda editarse.Prepares a cell for editing.

protected public:
 virtual void Edit(System::Windows::Forms::CurrencyManager ^ source, int rowNum, System::Drawing::Rectangle bounds, bool readOnly);
protected internal virtual void Edit (System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Rectangle bounds, bool readOnly);
abstract member Edit : System.Windows.Forms.CurrencyManager * int * System.Drawing.Rectangle * bool -> unit
override this.Edit : System.Windows.Forms.CurrencyManager * int * System.Drawing.Rectangle * bool -> unit
Protected Friend Overridable Sub Edit (source As CurrencyManager, rowNum As Integer, bounds As Rectangle, readOnly As Boolean)

Parámetros

rowNum
Int32

Número de fila que se va a editar.The row number to edit.

bounds
Rectangle

Rectangledelimitador donde se va a situar el control.The bounding Rectangle in which the control is to be sited.

readOnly
Boolean

Valor que indica si la columna es de solo lectura.A value indicating whether the column is a read-only. Es true si el valor es de solo lectura; en caso contrario, es false.true if the value is read-only; otherwise, false.

Comentarios

Normalmente, el Edit método localiza un control en la cuadrícula en la ubicación de la celda que se está editando.Typically, the Edit method sites a control onto the grid at the location of the cell being edited.

Se aplica a

Edit(CurrencyManager, Int32, Rectangle, Boolean, String)

Prepara la celda para la edición con el CurrencyManager, el número de fila y los parámetros Rectangle especificados.Prepares the cell for editing using the specified CurrencyManager, row number, and Rectangle parameters.

protected public:
 virtual void Edit(System::Windows::Forms::CurrencyManager ^ source, int rowNum, System::Drawing::Rectangle bounds, bool readOnly, System::String ^ displayText);
protected public:
 virtual void Edit(System::Windows::Forms::CurrencyManager ^ source, int rowNum, System::Drawing::Rectangle bounds, bool readOnly, System::String ^ instantText);
protected internal virtual void Edit (System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Rectangle bounds, bool readOnly, string displayText);
protected internal virtual void Edit (System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Rectangle bounds, bool readOnly, string instantText);
abstract member Edit : System.Windows.Forms.CurrencyManager * int * System.Drawing.Rectangle * bool * string -> unit
override this.Edit : System.Windows.Forms.CurrencyManager * int * System.Drawing.Rectangle * bool * string -> unit
abstract member Edit : System.Windows.Forms.CurrencyManager * int * System.Drawing.Rectangle * bool * string -> unit
override this.Edit : System.Windows.Forms.CurrencyManager * int * System.Drawing.Rectangle * bool * string -> unit
Protected Friend Overridable Sub Edit (source As CurrencyManager, rowNum As Integer, bounds As Rectangle, readOnly As Boolean, displayText As String)
Protected Friend Overridable Sub Edit (source As CurrencyManager, rowNum As Integer, bounds As Rectangle, readOnly As Boolean, instantText As String)

Parámetros

rowNum
Int32

Número de fila en esta columna que se está editando.The row number in this column which is being edited.

bounds
Rectangle

Rectangledonde se va a situar el control.The Rectangle in which the control is to be sited.

readOnly
Boolean

Valor que indica si la columna es de solo lectura.A value indicating whether the column is a read-only. Es true si el valor es de solo lectura; en caso contrario, es false.true if the value is read-only; otherwise, false.

displayTextinstantText
String

Texto que se va a mostrar en el control.The text to display in the control.

Ejemplos

En el ejemplo de código siguiente Edit se usa el método para cambiar el texto de una celda en la que se hace clic en el System.Windows.Forms.DataGrid control.The following code example uses the Edit method to change the text of a clicked cell in the System.Windows.Forms.DataGrid control.

public ref class Form1: public Form
{
private:
   DataSet^ myDataSet;
   void dataGrid1_MouseDown( Object^ sender, MouseEventArgs^ e )
   {
      // Use the HitTest method to get a HitTestInfo object.
      System::Windows::Forms::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 = grid->TableStyles[ 0 ];
         CurrencyManager^ myCurrencyManager = dynamic_cast<CurrencyManager^>(this->BindingContext[ myDataSet->Tables[ dgt->MappingName ] ]);

         // Get the Rectangle of the clicked cell.
         Rectangle cellRect;
         cellRect = grid->GetCellBounds( hi->Row, hi->Column );

         // Get the clicked DataGridTextBoxColumn.
         MyColumnStyle ^ gridCol = dynamic_cast<MyColumnStyle^>(dgt->GridColumnStyles[ hi->Column ]);

         // Edit the value.
         gridCol->EditVal( myCurrencyManager, hi->Row, cellRect, false, "New Text" );
      }
   }


public:
   ref class MyColumnStyle: public DataGridTextBoxColumn
   {
   public:
      void EditVal( CurrencyManager^ cm, int row, Rectangle rec, bool readOnly, String^ text )
      {
         this->Edit( cm, row, rec, readOnly, text );
      }
   };
};
public class Form1: Form
{
static void Main(){}

protected DataSet myDataSet;

private void dataGrid1_MouseDown(object sender, MouseEventArgs e)
{
    // Use the HitTest method to get a HitTestInfo object.
    System.Windows.Forms.DataGrid.HitTestInfo hi;   
    DataGrid grid = (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 = grid.TableStyles[0];     
       CurrencyManager myCurrencyManager = (CurrencyManager)
        this.BindingContext[myDataSet.Tables[dgt.MappingName]];
       // Get the Rectangle of the clicked cell.
       Rectangle cellRect;
       cellRect=grid.GetCellBounds(hi.Row, hi.Column);
       // Get the clicked DataGridTextBoxColumn.
       MyColumnStyle gridCol =(MyColumnStyle) 
       dgt.GridColumnStyles[hi.Column];
       // Edit the value.
       gridCol.EditVal(myCurrencyManager, hi.Row, cellRect, false, "New Text");
    }
 }

public class MyColumnStyle:DataGridTextBoxColumn{
    public void EditVal(CurrencyManager cm, int row, Rectangle rec, 
    bool readOnly, string text){
        this.Edit(cm, row, rec, readOnly, text);
    }
}
}
Public Class Form1
   Inherits Form

   Protected myDataSet As DataSet

   Shared Sub Main()
   End Sub
    
    Private Sub dataGrid1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
        ' Use the HitTest method to get a HitTestInfo object.
        Dim hi As System.Windows.Forms.DataGrid.HitTestInfo
        Dim grid As DataGrid = CType(sender, DataGrid)
        hi = grid.HitTest(e.X, e.Y)
        ' Test if the clicked area was a cell.
        If hi.Type = DataGrid.HitTestType.Cell Then
            ' If it's a cell, get the GridTable and CurrencyManager of the
            ' clicked table.         
            Dim dgt As DataGridTableStyle = grid.TableStyles(0)
            Dim myCurrencyManager As CurrencyManager = _
            CType(Me.BindingContext _
            (myDataSet.Tables(dgt.MappingName)), CurrencyManager)
            ' Get the Rectangle of the clicked cell.
            Dim cellRect As Rectangle
            cellRect = grid.GetCellBounds(hi.Row, hi.Column)
            ' Get the clicked DataGridTextBoxColumn.
            Dim gridCol As MyColumnStyle = CType(dgt.GridColumnStyles _
            (hi.Column), MyColumnStyle)
            ' Edit the value.
            gridCol.EditVal(myCurrencyManager, hi.Row, cellRect, False, "New Text")
        End If
    End Sub
End Class 

Public Class MyColumnStyle
   Inherits DataGridTextBoxColumn
   Public Sub EditVal(cm As CurrencyManager, row As Integer, _
   rec As Rectangle, bReadOnly As Boolean, text As String)
      MyBase.Edit(cm, row, rec, bReadOnly, text)
   End Sub
End Class

Comentarios

Normalmente, el Edit método localiza un control en la cuadrícula en la ubicación de la celda que se está editando.Typically, the Edit method sites a control onto the grid at the location of the cell being edited.

Se aplica a

Edit(CurrencyManager, Int32, Rectangle, Boolean, String, Boolean)

Cuando se reemplaza en una clase derivada, prepara una celda para su edición.When overridden in a deriving class, prepares a cell for editing.

protected public:
 abstract void Edit(System::Windows::Forms::CurrencyManager ^ source, int rowNum, System::Drawing::Rectangle bounds, bool readOnly, System::String ^ displayText, bool cellIsVisible);
protected public:
 abstract void Edit(System::Windows::Forms::CurrencyManager ^ source, int rowNum, System::Drawing::Rectangle bounds, bool readOnly, System::String ^ instantText, bool cellIsVisible);
protected internal abstract void Edit (System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Rectangle bounds, bool readOnly, string displayText, bool cellIsVisible);
protected internal abstract void Edit (System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Rectangle bounds, bool readOnly, string instantText, bool cellIsVisible);
abstract member Edit : System.Windows.Forms.CurrencyManager * int * System.Drawing.Rectangle * bool * string * bool -> unit
abstract member Edit : System.Windows.Forms.CurrencyManager * int * System.Drawing.Rectangle * bool * string * bool -> unit
Protected Friend MustOverride Sub Edit (source As CurrencyManager, rowNum As Integer, bounds As Rectangle, readOnly As Boolean, displayText As String, cellIsVisible As Boolean)
Protected Friend MustOverride Sub Edit (source As CurrencyManager, rowNum As Integer, bounds As Rectangle, readOnly As Boolean, instantText As String, cellIsVisible As Boolean)

Parámetros

rowNum
Int32

Número de fila en esta columna que se está editando.The row number in this column which is being edited.

bounds
Rectangle

Rectangledonde se va a situar el control.The Rectangle in which the control is to be sited.

readOnly
Boolean

Valor que indica si la columna es de solo lectura.A value indicating whether the column is a read-only. Es true si el valor es de solo lectura; en caso contrario, es false.true if the value is read-only; otherwise, false.

displayTextinstantText
String

Texto que se va a mostrar en el control.The text to display in the control.

cellIsVisible
Boolean

Valor que indica si la celda está visible.A value indicating whether the cell is visible. Es true si la celda está visible; en caso contrario, es false.true if the cell is visible; otherwise, false.

Comentarios

Normalmente, el Edit método localiza un control en la cuadrícula en la ubicación de la celda que se está editando.Typically, the Edit method sites a control onto the grid at the location of the cell being edited.

Se aplica a