Share via


DataGridViewRowPrePaintEventArgs.InheritedRowStyle Özellik

Tanım

Satıra uygulanan hücre stilini alır.

public:
 property System::Windows::Forms::DataGridViewCellStyle ^ InheritedRowStyle { System::Windows::Forms::DataGridViewCellStyle ^ get(); };
public System.Windows.Forms.DataGridViewCellStyle InheritedRowStyle { get; }
member this.InheritedRowStyle : System.Windows.Forms.DataGridViewCellStyle
Public ReadOnly Property InheritedRowStyle As DataGridViewCellStyle

Özellik Değeri

DataGridViewCellStyle Şu anda satıra uygulanmış olan hücre stilini içeren bir.

Örnekler

Aşağıdaki kod örneği, seçili satır için özel bir arka plan boyamak için özelliğinin nasıl kullanılacağını InheritedRowStyle gösterir. değişkeni, etüründedir DataGridViewRowPrePaintEventArgs. 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.

// 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

Açıklamalar

InheritedRowStyle özelliği, satırın InheritedStyle özelliğiyle aynı değerleri içerir. içinde DataGridView öğesine DataGridViewRow doğrudan erişmek performansı etkileyebilir. Satır paylaşımını RowPrePaint kaldırmayı önlemek ve en iyi performansı korumak için olayda kullanınInheritedRowStyle.

InheritedRowStyle özelliği salt okunurdur. özelliği aracılığıyla InheritedRowStyle alınan öğesinin DataGridViewCellStyle özelliklerini ayarlayabilirsiniz ancak yeni ayarların hiçbir etkisi olmaz.

Şunlara uygulanır

Ayrıca bkz.