DataGridColumnStyle.Edit Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Prepara a célula para editar um valor.
Sobrecargas
| Name | Description |
|---|---|
| Edit(CurrencyManager, Int32, Rectangle, Boolean) |
Prepara uma célula para edição. |
| Edit(CurrencyManager, Int32, Rectangle, Boolean, String) |
Prepara a célula para edição usando o número de linha e CurrencyManager parâmetros especificadosRectangle. |
| Edit(CurrencyManager, Int32, Rectangle, Boolean, String, Boolean) |
Quando sobrescrito numa classe derivadora, prepara uma célula para edição. |
Edit(CurrencyManager, Int32, Rectangle, Boolean)
- Origem:
- DataGridColumnStyle.cs
- Origem:
- DataGridColumnStyle.cs
Prepara uma célula para edição.
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
- source
- CurrencyManager
O CurrencyManager para o DataGridColumnStyle.
- rowNum
- Int32
O número da linha a editar.
- readOnly
- Boolean
Um valor que indica se a coluna é apenas de leitura.
true se o valor for apenas de leitura; caso contrário, false.
Observações
Normalmente, o Edit método coloca um controlo na grelha no local da célula que está a ser editada.
Aplica-se a
Edit(CurrencyManager, Int32, Rectangle, Boolean, String)
- Origem:
- DataGridColumnStyle.cs
- Origem:
- DataGridColumnStyle.cs
Prepara a célula para edição usando o número de linha e CurrencyManager parâmetros especificadosRectangle.
protected public:
virtual void Edit(System::Windows::Forms::CurrencyManager ^ source, int rowNum, System::Drawing::Rectangle bounds, bool readOnly, System::String ^ instantText);
protected public:
virtual void Edit(System::Windows::Forms::CurrencyManager ^ source, int rowNum, System::Drawing::Rectangle bounds, bool readOnly, System::String ^ displayText);
protected internal virtual void Edit(System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Rectangle bounds, bool readOnly, string instantText);
protected internal virtual void Edit(System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Rectangle bounds, bool readOnly, string displayText);
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, instantText As String)
Protected Friend Overridable Sub Edit (source As CurrencyManager, rowNum As Integer, bounds As Rectangle, readOnly As Boolean, displayText As String)
Parâmetros
- source
- CurrencyManager
O CurrencyManager para o DataGridColumnStyle.
- rowNum
- Int32
O número da linha nesta coluna que está a ser editado.
- readOnly
- Boolean
Um valor que indica se a coluna é apenas de leitura.
true se o valor for apenas de leitura; caso contrário, false.
- instantTextdisplayText
- String
O texto para mostrar no controlo.
Exemplos
O exemplo de código seguinte utiliza o método Edit para alterar o texto de uma célula clicada no controlo System.Windows.Forms.DataGrid.
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
Observações
Normalmente, o Edit método coloca um controlo na grelha no local da célula que está a ser editada.
Aplica-se a
Edit(CurrencyManager, Int32, Rectangle, Boolean, String, Boolean)
- Origem:
- DataGridColumnStyle.cs
- Origem:
- DataGridColumnStyle.cs
Quando sobrescrito numa classe derivadora, prepara uma célula para edição.
protected public:
abstract void Edit(System::Windows::Forms::CurrencyManager ^ source, int rowNum, System::Drawing::Rectangle bounds, bool readOnly, System::String ^ instantText, bool cellIsVisible);
protected public:
abstract void Edit(System::Windows::Forms::CurrencyManager ^ source, int rowNum, System::Drawing::Rectangle bounds, bool readOnly, System::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);
protected internal abstract void Edit(System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Rectangle bounds, bool readOnly, string displayText, 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, instantText As String, cellIsVisible As Boolean)
Protected Friend MustOverride Sub Edit (source As CurrencyManager, rowNum As Integer, bounds As Rectangle, readOnly As Boolean, displayText As String, cellIsVisible As Boolean)
Parâmetros
- source
- CurrencyManager
O CurrencyManager para o DataGridColumnStyle.
- rowNum
- Int32
O número da linha nesta coluna que está a ser editado.
- readOnly
- Boolean
Um valor que indica se a coluna é apenas de leitura.
true se o valor for apenas de leitura; caso contrário, false.
- instantTextdisplayText
- String
O texto para mostrar no controlo.
- cellIsVisible
- Boolean
Um valor que indica se a célula é visível.
true se a célula for visível; caso contrário, false.
Observações
Normalmente, o Edit método coloca um controlo na grelha no local da célula que está a ser editada.