DataGridViewRowPrePaintEventArgs 클래스

정의

RowPrePaint 이벤트에 대한 데이터를 제공합니다.

public ref class DataGridViewRowPrePaintEventArgs : System::ComponentModel::HandledEventArgs
public class DataGridViewRowPrePaintEventArgs : System.ComponentModel.HandledEventArgs
type DataGridViewRowPrePaintEventArgs = class
    inherit HandledEventArgs
Public Class DataGridViewRowPrePaintEventArgs
Inherits HandledEventArgs
상속
DataGridViewRowPrePaintEventArgs

예제

다음 코드 예제에서는 선택한 셀에 RowPrePaint 대 한 사용자 지정 배경을 그리기 위해 이벤트를 처리 하는 방법을 보여 줍니다. 이 코드 예제는에서 제공 하는 더 큰 예제의 일부입니다 방법: Windows Forms DataGridView 컨트롤에서 행 모양 사용자 지정합니다.

// Paints the custom selection background for selected rows.
void dataGridView1_RowPrePaint(object sender,
        DataGridViewRowPrePaintEventArgs e)
{
    // Do not automatically paint the focus rectangle.
    e.PaintParts &= ~DataGridViewPaintParts.Focus;

    // 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);
        }
    }
}
' Paints the custom selection background for selected rows.
Sub dataGridView1_RowPrePaint(ByVal sender As Object, _
    ByVal e As DataGridViewRowPrePaintEventArgs) _
    Handles dataGridView1.RowPrePaint

    ' Do not automatically paint the focus rectangle.
    e.PaintParts = e.PaintParts And Not DataGridViewPaintParts.Focus

    ' 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

End Sub

설명

이벤트는 RowPrePaint 컨트롤에 DataGridView 행이 그려지기 전에 발생합니다. RowPrePaint 행의 셀을 그리기 전에 행의 모양을 수동으로 조정할 수 있습니다. 이는 한 열의 내용이 여러 열에 걸쳐 있는 행을 생성하는 등 행을 사용자 지정하려는 경우에 유용합니다. 의 속성을 DataGridViewRowPrePaintEventArgs 사용하여 의 행에 직접 액세스하지 않고 행 DataGridView의 설정을 가져옵니다.

생성자

DataGridViewRowPrePaintEventArgs(DataGridView, Graphics, Rectangle, Rectangle, Int32, DataGridViewElementStates, String, DataGridViewCellStyle, Boolean, Boolean)

DataGridViewRowPrePaintEventArgs 클래스의 새 인스턴스를 초기화합니다.

속성

ClipBounds

다시 그려야 하는 DataGridView의 영역을 가져오거나 설정합니다.

ErrorText

현재 DataGridViewRow에 대한 오류 메시지를 나타내는 문자열을 가져옵니다.

Graphics

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

Handled

이벤트 처리기에서 이벤트를 완전히 처리했는지 아니면 시스템에서 처리를 계속해야 하는지를 나타내는 값을 가져오거나 설정합니다.

(다음에서 상속됨 HandledEventArgs)
InheritedRowStyle

행에 적용된 셀 스타일을 가져옵니다.

IsFirstDisplayedRow

현재 행이 DataGridView에 현재 표시되는 첫 번째 행인지 여부를 나타내는 값을 가져옵니다.

IsLastVisibleRow

현재 행이 DataGridView에 표시되는 마지막 행인지 여부를 나타내는 값을 가져옵니다.

PaintParts

그릴 셀 부분입니다.

RowBounds

현재 DataGridViewRow의 범위를 가져옵니다.

RowIndex

현재 DataGridViewRow의 인덱스를 가져옵니다.

State

현재 DataGridViewRow의 상태를 가져옵니다.

메서드

DrawFocus(Rectangle, Boolean)

지정된 범위 주위에 포커스 영역을 그립니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
PaintCells(Rectangle, DataGridViewPaintParts)

지정된 범위의 영역에 지정된 셀 부분을 그립니다.

PaintCellsBackground(Rectangle, Boolean)

지정된 범위의 영역에 셀 배경을 그립니다.

PaintCellsContent(Rectangle)

지정된 범위의 영역에 셀 내용을 그립니다.

PaintHeader(Boolean)

현재 DataGridViewRow의 전체 행 머리글을 그립니다.

PaintHeader(DataGridViewPaintParts)

현재 행에 대한 행 머리글의 지정된 부분을 그립니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보