DataGridViewRowPostPaintEventArgs.Graphics 속성

정의

현재 Graphics을 그리는 데 사용되는 DataGridViewRow를 가져옵니다.

public:
 property System::Drawing::Graphics ^ Graphics { System::Drawing::Graphics ^ get(); };
public System.Drawing.Graphics Graphics { get; }
member this.Graphics : System.Drawing.Graphics
Public ReadOnly Property Graphics As Graphics

속성 값

Graphics

Graphics을 그리는 데 사용되는 DataGridViewRow입니다.

예제

다음 코드 예제에서는 사용자 지정 배경을 그리기 위해 속성을 사용 Graphics 하는 방법을 보여 줍니다. 코드에서 실제로 속성을 사용 DataGridViewRowPrePaintEventArgs.Graphics 하지만 이 속성은 .의 DataGridViewRowPostPaintEventArgs속성과 Graphics 거의 동일합니다. 변수는 e형식입니다 DataGridViewRowPrePaintEventArgs. 이 코드 예제는에서 제공 하는 더 큰 예제의 일부입니다 방법: Windows Forms DataGridView 컨트롤에서 행 모양 사용자 지정합니다.

// Determine whether the cell should be painted
// with the custom selection background.
if ((e.State & DataGridViewElementStates.Selected) ==
            DataGridViewElementStates.Selected)
{
    // Calculate the bounds of the row.
    Rectangle rowBounds = new Rectangle(
        this.dataGridView1.RowHeadersWidth, e.RowBounds.Top,
        this.dataGridView1.Columns.GetColumnsWidth(
            DataGridViewElementStates.Visible) -
        this.dataGridView1.HorizontalScrollingOffset + 1,
        e.RowBounds.Height);

    // Paint the custom selection background.
    using (Brush backbrush =
        new System.Drawing.Drawing2D.LinearGradientBrush(rowBounds,
            this.dataGridView1.DefaultCellStyle.SelectionBackColor,
            e.InheritedRowStyle.ForeColor,
            System.Drawing.Drawing2D.LinearGradientMode.Horizontal))
    {
        e.Graphics.FillRectangle(backbrush, rowBounds);
    }
}
' Determine whether the cell should be painted with the 
' custom selection background.
If (e.State And DataGridViewElementStates.Selected) = _
    DataGridViewElementStates.Selected Then

    ' Calculate the bounds of the row.
    Dim rowBounds As New Rectangle( _
        Me.dataGridView1.RowHeadersWidth, e.RowBounds.Top, _
        Me.dataGridView1.Columns.GetColumnsWidth( _
        DataGridViewElementStates.Visible) - _
        Me.dataGridView1.HorizontalScrollingOffset + 1, _
        e.RowBounds.Height)

    ' Paint the custom selection background.
    Dim backbrush As New _
        System.Drawing.Drawing2D.LinearGradientBrush(rowBounds, _
        Me.dataGridView1.DefaultCellStyle.SelectionBackColor, _
        e.InheritedRowStyle.ForeColor, _
        System.Drawing.Drawing2D.LinearGradientMode.Horizontal)
    Try
        e.Graphics.FillRectangle(backbrush, rowBounds)
    Finally
        backbrush.Dispose()
    End Try
End If

설명

클래스는 Graphics 사용자 지정 그리기에 유용한 속성 및 메서드를 제공합니다.

적용 대상

추가 정보