Taal

DataGridViewRowPrePaintEventArgs.InheritedRowStyle Eigenschap

Definitie

Hiermee wordt de celstijl toegepast op de rij.

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

Waarde van eigenschap

Een DataGridViewCellStyle met de celstijl die momenteel op de rij is toegepast.

Voorbeelden

In het volgende codevoorbeeld ziet u hoe u de InheritedRowStyle eigenschap gebruikt om een aangepaste achtergrond voor de geselecteerde rij te schilderen. De variabele, eis van het type DataGridViewRowPrePaintEventArgs. Dit codevoorbeeld maakt deel uit van een groter voorbeeld in How to: Het uiterlijk van rijen aanpassen in het Windows Forms DataGridView-besturingselement.

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

Opmerkingen

De InheritedRowStyle eigenschap bevat dezelfde waarden als de eigenschap van InheritedStyle de rij. Rechtstreeks toegang tot een DataGridViewRow in de database kan van invloed zijn op de DataGridView prestaties. Gebruik InheritedRowStyle in de gebeurtenis om te RowPrePaint voorkomen dat de rij wordt gedeeld en optimale prestaties te behouden.

De InheritedRowStyle eigenschap heeft het kenmerk Alleen-lezen. Hoewel u de eigenschappen van de DataGridViewCellStyle opgehaalde eigenschappen via de InheritedRowStyle eigenschap kunt instellen, hebben de nieuwe instellingen geen effect.

Van toepassing op

Zie ook