DataGridTextBoxColumn.Paint 메서드

정의

컨트롤의 열을 그립니다 DataGrid .

오버로드

Name Description
Paint(Graphics, Rectangle, CurrencyManager, Int32)

지정된 DataGridColumnStyle, Graphics, Rectangle및 행 번호를 사용하여 a CurrencyManager 를 그립니다.

Paint(Graphics, Rectangle, CurrencyManager, Int32, Boolean)

지정된 DataGridColumnStyle, , GraphicsRectangle번호 및 맞춤을 사용하여 A CurrencyManager 를 그립니다.

Paint(Graphics, Rectangle, CurrencyManager, Int32, Brush, Brush, Boolean)

지정된 DataGridColumnStyle, , 행 GraphicsRectangle번호 CurrencyManager및 전경색을 사용하여 A Brush 를 그립니다.

Paint(Graphics, Rectangle, CurrencyManager, Int32)

Source:
DataGridTextBoxColumn.cs
Source:
DataGridTextBoxColumn.cs

지정된 DataGridColumnStyle, Graphics, Rectangle및 행 번호를 사용하여 a CurrencyManager 를 그립니다.

protected public:
 override void Paint(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, System::Windows::Forms::CurrencyManager ^ source, int rowNum);
protected internal override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Windows.Forms.CurrencyManager source, int rowNum);
override this.Paint : System.Drawing.Graphics * System.Drawing.Rectangle * System.Windows.Forms.CurrencyManager * int -> unit
Protected Friend Overrides Sub Paint (g As Graphics, bounds As Rectangle, source As CurrencyManager, rowNum As Integer)

매개 변수

g
Graphics

Graphics 그릴 개체입니다.

bounds
Rectangle

그릴 경계 Rectangle 입니다.

source
CurrencyManager

CurrencyManager 열이 DataGrid 들어 있는 열의 입니다.

rowNum
Int32

기본 데이터 테이블의 행 수입니다.

추가 정보

적용 대상

Paint(Graphics, Rectangle, CurrencyManager, Int32, Boolean)

Source:
DataGridTextBoxColumn.cs
Source:
DataGridTextBoxColumn.cs

지정된 DataGridColumnStyle, , GraphicsRectangle번호 및 맞춤을 사용하여 A CurrencyManager 를 그립니다.

protected public:
 override void Paint(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, System::Windows::Forms::CurrencyManager ^ source, int rowNum, bool alignToRight);
protected internal override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Windows.Forms.CurrencyManager source, int rowNum, bool alignToRight);
override this.Paint : System.Drawing.Graphics * System.Drawing.Rectangle * System.Windows.Forms.CurrencyManager * int * bool -> unit
Protected Friend Overrides Sub Paint (g As Graphics, bounds As Rectangle, source As CurrencyManager, rowNum As Integer, alignToRight As Boolean)

매개 변수

g
Graphics

Graphics 그릴 개체입니다.

bounds
Rectangle

그릴 경계 Rectangle 입니다.

source
CurrencyManager

CurrencyManager 열이 DataGrid 들어 있는 열의 입니다.

rowNum
Int32

기본 데이터 테이블의 행 수입니다.

alignToRight
Boolean

열 내용을 오른쪽에 맞출지 여부를 나타내는 값입니다. true콘텐츠를 오른쪽에 맞춰야 하면 이고, 그렇지 않으면 . false

설명

이 메서드는 PaintGetColumnValueAtRow 값을 사용하여 셀에 그릴 값을 결정합니다. 이 PaintText 메서드는 셀과 해당 내용을 그리기 위해 호출됩니다.

추가 정보

적용 대상

Paint(Graphics, Rectangle, CurrencyManager, Int32, Brush, Brush, Boolean)

지정된 DataGridColumnStyle, , 행 GraphicsRectangle번호 CurrencyManager및 전경색을 사용하여 A Brush 를 그립니다.

protected public:
 override void Paint(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, System::Windows::Forms::CurrencyManager ^ source, int rowNum, System::Drawing::Brush ^ backBrush, System::Drawing::Brush ^ foreBrush, bool alignToRight);
protected internal override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Brush backBrush, System.Drawing.Brush foreBrush, bool alignToRight);
override this.Paint : System.Drawing.Graphics * System.Drawing.Rectangle * System.Windows.Forms.CurrencyManager * int * System.Drawing.Brush * System.Drawing.Brush * bool -> unit
Protected Friend Overrides Sub Paint (g As Graphics, bounds As Rectangle, source As CurrencyManager, rowNum As Integer, backBrush As Brush, foreBrush As Brush, alignToRight As Boolean)

매개 변수

g
Graphics

Graphics 그릴 개체입니다.

bounds
Rectangle

그릴 경계 Rectangle 입니다.

source
CurrencyManager

CurrencyManager 열이 DataGrid 들어 있는 열의 입니다.

rowNum
Int32

기본 데이터 테이블의 행 수입니다.

backBrush
Brush

배경을 그리는 A Brush 입니다.

foreBrush
Brush

전경색을 그리는 A Brush 입니다.

alignToRight
Boolean

열 내용을 오른쪽에 맞출지 여부를 나타내는 값입니다. true콘텐츠를 오른쪽에 맞춰야 하면 이고, 그렇지 않으면 . false

예제

다음 예제에서는 메서드를 Paint 사용하여 새 전경색과 배경색으로 클릭된 셀을 그립니다.

public ref class MyGridColumn: public DataGridTextBoxColumn
{
public:
   void PaintCol( Graphics^ g, Rectangle cellRect, CurrencyManager^ cm, int rowNum, Brush^ bBrush, Brush^ fBrush, bool isVisible )
   {
      this->Paint( g, cellRect, cm, rowNum, bBrush, fBrush, isVisible );
   }

};

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

private:
   void PaintCell( 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 ListManager 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;
         cellRect = grid->GetCellBounds( hi->Row, hi->Column );
         
         // Get the clicked DataGridTextBoxColumn.
         MyGridColumn^ gridCol = dynamic_cast<MyGridColumn^>(dgt->GridColumnStyles[ hi->Column ]);
         
         // Get the Graphics object for the form.
         Graphics^ g = dataGrid1->CreateGraphics();
         
         // Create two new Brush objects, a fore brush, and back brush.
         Brush^ fBrush = gcnew System::Drawing::SolidBrush( Color::Blue );
         Brush^ bBrush = gcnew System::Drawing::SolidBrush( Color::Yellow );
         
         // Invoke the Paint method to paint the cell with the brushes.
         gridCol->PaintCol( g, cellRect, cm, hi->Row, bBrush, fBrush, false );
      }
   }

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

private void PaintCell(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 ListManager 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;
       cellRect=grid.GetCellBounds(hi.Row, hi.Column);
       // Get the clicked DataGridTextBoxColumn.
       MyGridColumn  gridCol =(MyGridColumn)dgt.GridColumnStyles[hi.Column];
       // Get the Graphics object for the form.
       Graphics g = dataGrid1.CreateGraphics();
       // Create two new Brush objects, a fore brush, and back brush.
       Brush fBrush = new System.Drawing.SolidBrush(Color.Blue);
       Brush bBrush= new System.Drawing.SolidBrush(Color.Yellow);
       // Invoke the Paint method to paint the cell with the brushes.
       gridCol.PaintCol(g, cellRect, cm, hi.Row, bBrush, fBrush, false);
     }
 }
}

public class MyGridColumn:DataGridTextBoxColumn{
   public void PaintCol(Graphics g, Rectangle cellRect, 
    CurrencyManager cm, int rowNum, Brush bBrush, 
    Brush fBrush, bool isVisible){
      this.Paint(g, cellRect, cm, rowNum, bBrush, fBrush, isVisible);
   }
}
Public Class Form1
   Inherits Form
   Protected dataGrid1 As DataGrid
   Protected myDataSet As DataSet
    
   Private Sub PaintCell(sender As Object, 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 ListManager 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
         cellRect = grid.GetCellBounds(hi.Row, hi.Column)
         ' Get the clicked DataGridTextBoxColumn.
         Dim gridCol As MyGridColumn = CType _
         (dgt.GridColumnStyles(hi.Column), MyGridColumn)
         ' Get the Graphics object for the form.
         Dim g As Graphics = dataGrid1.CreateGraphics()
         ' Create two new Brush objects: a fore brush and back brush.
         Dim fBrush As New SolidBrush(Color.Blue)
         Dim bBrush As New SolidBrush(Color.Yellow)
         ' Invoke the Paint method to paint the cell with the brushes.
         gridCol.PaintCol(g, cellRect, cm, hi.Row, bBrush, fBrush, False)
      End If
   End Sub
End Class

Public Class MyGridColumn
Inherits DataGridTextBoxColumn
   Public Sub PaintCol(g As Graphics , cellRect As Rectangle , _
      cm As CurrencyManager , rowNum As integer , bBrush as Brush , _
      fBrush As Brush , isVisible As Boolean )
      me.Paint(g, cellRect, cm, rowNum, bBrush, fBrush, isVisible)
   End Sub
End Class

설명

이 메서드는 PaintGetColumnValueAtRow 값을 사용하여 셀에 그릴 값을 결정합니다. 이 PaintText 메서드는 셀과 해당 내용을 그리기 위해 호출됩니다.

추가 정보

적용 대상