İngilizce dilinde oku

Aracılığıyla paylaş


DataGridViewRowPostPaintEventArgs Sınıf

Tanım

RowPostPaint olayı için veriler sağlar.

C#
public class DataGridViewRowPostPaintEventArgs : 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.

C#
// 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);
    }
}

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

Ö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

Ürün Sürümler
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Ayrıca bkz.