DataGridViewRowPostPaintEventArgs Sınıf

Tanım

RowPostPaint olayı için veriler sağlar.

public ref class DataGridViewRowPostPaintEventArgs : EventArgs
public class DataGridViewRowPostPaintEventArgs : EventArgs
type DataGridViewRowPostPaintEventArgs = class
    inherit EventArgs
Public Class DataGridViewRowPostPaintEventArgs
Inherits EventArgs
Devralma
DataGridViewRowPostPaintEventArgs

Örnekler

Aşağıdaki kod örneği, bir hücrenin içeriğinin satırın RowPostPaint tamamına yayılması için olayı işlemeyi gösterir. Bu kod örneği, Nasıl yapılır: Windows Forms DataGridView Denetimindeki Satırların Görünümünü Özelleştirme bölümünde sağlanan daha büyük bir örneğin parçasıdır.

// Paints the content that spans multiple columns and the focus rectangle.
void dataGridView1_RowPostPaint(object sender,
    DataGridViewRowPostPaintEventArgs e)
{
    // 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);

    SolidBrush forebrush = null;
    try
    {
        // Determine the foreground color.
        if ((e.State & DataGridViewElementStates.Selected) ==
            DataGridViewElementStates.Selected)
        {
            forebrush = new SolidBrush(e.InheritedRowStyle.SelectionForeColor);
        }
        else
        {
            forebrush = new SolidBrush(e.InheritedRowStyle.ForeColor);
        }

        // Get the content that spans multiple columns.
        object recipe =
            this.dataGridView1.Rows.SharedRow(e.RowIndex).Cells[2].Value;

        if (recipe != null)
        {
            String text = recipe.ToString();

            // Calculate the bounds for the content that spans multiple 
            // columns, adjusting for the horizontal scrolling position 
            // and the current row height, and displaying only whole
            // lines of text.
            Rectangle textArea = rowBounds;
            textArea.X -= this.dataGridView1.HorizontalScrollingOffset;
            textArea.Width += this.dataGridView1.HorizontalScrollingOffset;
            textArea.Y += rowBounds.Height - e.InheritedRowStyle.Padding.Bottom;
            textArea.Height -= rowBounds.Height -
                e.InheritedRowStyle.Padding.Bottom;
            textArea.Height = (textArea.Height / e.InheritedRowStyle.Font.Height) *
                e.InheritedRowStyle.Font.Height;

            // Calculate the portion of the text area that needs painting.
            RectangleF clip = textArea;
            clip.Width -= this.dataGridView1.RowHeadersWidth + 1 - clip.X;
            clip.X = this.dataGridView1.RowHeadersWidth + 1;
            RectangleF oldClip = e.Graphics.ClipBounds;
            e.Graphics.SetClip(clip);

            // Draw the content that spans multiple columns.
            e.Graphics.DrawString(
                text, e.InheritedRowStyle.Font, forebrush, textArea);

            e.Graphics.SetClip(oldClip);
        }
    }
    finally
    {
        forebrush.Dispose();
    }

    if (this.dataGridView1.CurrentCellAddress.Y == e.RowIndex)
    {
        // Paint the focus rectangle.
        e.DrawFocus(rowBounds, true);
    }
}
' Paints the content that spans multiple columns and the focus rectangle.
Sub dataGridView1_RowPostPaint(ByVal sender As Object, _
    ByVal e As DataGridViewRowPostPaintEventArgs) _
    Handles dataGridView1.RowPostPaint

    ' 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)

    Dim forebrush As SolidBrush = Nothing
    Try
        ' Determine the foreground color.
        If (e.State And DataGridViewElementStates.Selected) = _
            DataGridViewElementStates.Selected Then

            forebrush = New SolidBrush(e.InheritedRowStyle.SelectionForeColor)
        Else
            forebrush = New SolidBrush(e.InheritedRowStyle.ForeColor)
        End If

        ' Get the content that spans multiple columns.
        Dim recipe As Object = _
            Me.dataGridView1.Rows.SharedRow(e.RowIndex).Cells(2).Value

        If (recipe IsNot Nothing) Then
            Dim text As String = recipe.ToString()

            ' Calculate the bounds for the content that spans multiple 
            ' columns, adjusting for the horizontal scrolling position 
            ' and the current row height, and displaying only whole
            ' lines of text.
            Dim textArea As Rectangle = rowBounds
            textArea.X -= Me.dataGridView1.HorizontalScrollingOffset
            textArea.Width += Me.dataGridView1.HorizontalScrollingOffset
            textArea.Y += rowBounds.Height - e.InheritedRowStyle.Padding.Bottom
            textArea.Height -= rowBounds.Height - e.InheritedRowStyle.Padding.Bottom
            textArea.Height = (textArea.Height \ e.InheritedRowStyle.Font.Height) * _
                e.InheritedRowStyle.Font.Height

            ' Calculate the portion of the text area that needs painting.
            Dim clip As RectangleF = textArea
            clip.Width -= Me.dataGridView1.RowHeadersWidth + 1 - clip.X
            clip.X = Me.dataGridView1.RowHeadersWidth + 1
            Dim oldClip As RectangleF = e.Graphics.ClipBounds
            e.Graphics.SetClip(clip)

            ' Draw the content that spans multiple columns.
            e.Graphics.DrawString(text, e.InheritedRowStyle.Font, forebrush, _
                textArea)

            e.Graphics.SetClip(oldClip)
        End If
    Finally
        forebrush.Dispose()
    End Try

    If Me.dataGridView1.CurrentCellAddress.Y = e.RowIndex Then
        ' Paint the focus rectangle.
        e.DrawFocus(rowBounds, True)
    End If

End Sub

Açıklamalar

Olay, RowPostPaint bir satır denetime DataGridView boyandıktan sonra gerçekleşir. RowPostPaint satırdaki hücreler boyandıktan sonra satırın görünümünü el ile ayarlamanıza olanak tanır. Bu, satırı özelleştirmek istiyorsanız kullanışlıdır.

Oluşturucular

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

DataGridViewRowPostPaintEventArgs sınıfının yeni bir örneğini başlatır.

Özellikler

ClipBounds

öğesinin yeniden boyanması DataGridView gereken alanını alır veya ayarlar.

ErrorText

Geçerli DataGridViewRowiçin hata iletisini temsil eden bir dize alır.

Graphics

Geçerli DataGridViewRowöğesini Graphics boyamak için kullanılan öğesini alır.

InheritedRowStyle

Geçerli DataGridViewRowöğesine uygulanan hücre stilini alır.

IsFirstDisplayedRow

Geçerli satırın içinde DataGridViewgörüntülenen ilk satır olup olmadığını gösteren bir değer alır.

IsLastVisibleRow

Geçerli satırın içinde DataGridViewgörüntülenen son görünür satır olup olmadığını belirten bir değer alır.

RowBounds

Geçerli DataGridViewRowöğesinin sınırlarını alır.

RowIndex

Geçerli DataGridViewRowdizinini alır.

State

Geçerli DataGridViewRowdurumunu alır.

Yöntemler

DrawFocus(Rectangle, Boolean)

Odak dikdörtgenini belirtilen sınırların etrafına çizer.

Equals(Object)

Belirtilen nesnenin geçerli nesneye eşit olup olmadığını belirler.

(Devralındığı yer: Object)
GetHashCode()

Varsayılan karma işlevi işlevi görür.

(Devralındığı yer: Object)
GetType()

Type Geçerli örneğini alır.

(Devralındığı yer: Object)
MemberwiseClone()

Geçerli Objectöğesinin sığ bir kopyasını oluşturur.

(Devralındığı yer: Object)
PaintCells(Rectangle, DataGridViewPaintParts)

Belirtilen sınırlardaki alan için belirtilen hücre parçalarını boyar.

PaintCellsBackground(Rectangle, Boolean)

Belirtilen sınırlardaki alanın hücre arka planlarını boyar.

PaintCellsContent(Rectangle)

Belirtilen sınırlardaki alanın hücre içeriğini boyar.

PaintHeader(Boolean)

Geçerli DataGridViewRowöğesinin tüm satır üst bilgisini boyar.

PaintHeader(DataGridViewPaintParts)

Geçerli satırın satır üst bilgisinin belirtilen bölümlerini boyar.

ToString()

Geçerli nesneyi temsil eden dizeyi döndürür.

(Devralındığı yer: Object)

Şunlara uygulanır

Ayrıca bkz.