DataGridViewRowPostPaintEventArgs.InheritedRowStyle Egenskap
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Hämtar cellformatet som tillämpas på den aktuella DataGridViewRow.
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
Egenskapsvärde
A DataGridViewCellStyle som innehåller cellformatet som tillämpas på den aktuella DataGridViewRow.
Exempel
Följande kodexempel visar hur du använder InheritedRowStyle för att fastställa vilken färg som ska användas för att rita innehållet. Variabeln , eär av typen DataGridViewRowPostPaintEventArgs. Det här kodexemplet är en del av ett större exempel i Så här: Anpassa utseendet på rader i Windows Forms DataGridView Control.
// Determine the foreground color.
if ((e.State & DataGridViewElementStates.Selected) ==
DataGridViewElementStates.Selected)
{
forebrush = new SolidBrush(e.InheritedRowStyle.SelectionForeColor);
}
else
{
forebrush = new SolidBrush(e.InheritedRowStyle.ForeColor);
}
' 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
Kommentarer
Egenskapen InheritedRowStyle innehåller samma värden som den aktuella radens InheritedStyle egenskap. Direktåtkomst till en DataGridViewRow i DataGridView kan påverka prestanda. Använd InheritedRowStyle i händelse av RowPostPaint att undvika att dela upp raden och upprätthålla optimala prestanda.
Egenskapen InheritedRowStyle är skrivskyddad. Även om du kan ange egenskaperna för de DataGridViewCellStyle som hämtats via InheritedRowStyle egenskapen har de nya inställningarna ingen effekt.