DataGridTextBoxColumn.Edit 메서드

정의

편집할 셀을 준비합니다.

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

매개 변수

source
CurrencyManager

열이 속하는 CurrencyManager 컨트롤의 DataGrid입니다.

rowNum
Int32

편집되고 있는 이 열의 행 번호입니다.

bounds
Rectangle

컨트롤이 위치할 경계 Rectangle입니다.

readOnly
Boolean

열이 읽기 전용인지 여부를 나타내는 값입니다. 값이 읽기 전용이면 true이고, 그렇지 않으면 false입니다.

instantTextdisplayText
String

컨트롤에 표시할 텍스트입니다.

cellIsVisible
Boolean

셀을 표시할지 여부를 나타내는 값입니다. 셀이 표시되면 true이고, 그렇지 않으면 false입니다.

예제

다음 예제에서는 메서드를 Edit 사용하여 컨트롤에서 클릭한 셀 DataGrid 의 텍스트를 변경합니다.

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 );
      }
   }

};
public class Form1: Form
{
protected DataGrid dataGrid1;
protected DataSet myDataSet;

private void dataGrid1_MouseDown(object sender, MouseEventArgs e)
{
    // Use the HitTest method to get a HitTestInfo object.
    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 = dataGrid1.TableStyles[0];     
       CurrencyManager cm = (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 =
       (MyGridColumn)dgt.GridColumnStyles[hi.Column];
       // Edit the value.
       gridCol.EditCol(cm, hi.Row, cellRect, false, "New Text", true);
    }
 }
}

public class MyGridColumn: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 Class Form1
   Inherits Form
   Protected dataGrid1 As DataGrid
   Protected myDataSet As DataSet
    
   
    Private Sub dataGrid1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
        ' Use the HitTest method to get a HitTestInfo object.
        Dim hi As 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 = dataGrid1.TableStyles(0)
            Dim cm As CurrencyManager = CType _
            (Me.BindingContext(myDataSet.Tables(dgt.MappingName)), _
            CurrencyManager)
            ' Get the Rectangle of the clicked cell.
            Dim cellRect As Rectangle = _
            grid.GetCellBounds(hi.Row, hi.Column)
            ' Get the clicked DataGridTextBoxColumn.
            Dim gridCol As MyGridColumn = CType _
            (dgt.GridColumnStyles(hi.Column), MyGridColumn)
            ' Edit the value.
            gridCol.EditCol(cm, hi.Row, cellRect, False, "New Text", True)
        End If
    End Sub
End Class 

Public Class MyGridColumn
Inherits DataGridTextBoxColumn
   Public Sub EditCol(cm As CurrencyManager , rowNum As integer , _
   cellRect As Rectangle , bReadOnly As Boolean , _
   myString As String , isVisible As Boolean )
      me.Edit(cm, rowNum, cellRect, bReadOnly, myString, isVisible)
   End Sub
End Class

설명

Edit 편집할 셀의 위치에 있는 표에 컨트롤이 있는 사이트 TextBox 입니다. 편집 작업을 시작하려고 할 때 클래스의 BeginEdit 메서드에서 메서드를 호출 DataGrid 합니다.

적용 대상

추가 정보