DataGridViewRowPrePaintEventArgs.InheritedRowStyle プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DataGridViewRowPrePaintEventArgs.InheritedRowStyle プロパティの意味・解説 

DataGridViewRowPrePaintEventArgs.InheritedRowStyle プロパティ

メモ : このプロパティは、.NET Framework version 2.0 で新しく追加されたものです。

行に適用されるセル スタイルを取得します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public ReadOnly Property
 InheritedRowStyle As DataGridViewCellStyle
Dim instance As DataGridViewRowPrePaintEventArgs
Dim value As DataGridViewCellStyle

value = instance.InheritedRowStyle
public DataGridViewCellStyle InheritedRowStyle { get;
 }
public:
property DataGridViewCellStyle^ InheritedRowStyle {
    DataGridViewCellStyle^ get ();
}
/** @property */
public DataGridViewCellStyle get_InheritedRowStyle ()
public function get InheritedRowStyle
 () : DataGridViewCellStyle

プロパティ値
行に現在適用されているセル スタイルが格納された DataGridViewCellStyle。

解説解説

InheritedRowStyle プロパティには、行の InheritedStyle プロパティと同じ値が格納されます。DataGridView の DataGridViewRow に直接アクセスすると、パフォーマンスに影響を及ぼす可能性があります。行の共有解除を回避し、最適なパフォーマンスを維持するには、RowPrePaint イベントで InheritedRowStyle を使用します。

InheritedRowStyle プロパティは読み取り専用です。InheritedRowStyle プロパティを通じて取得した DataGridViewCellStyle のプロパティには新しい値を設定することもできますが、その設定は無効になります。

使用例使用例

InheritedRowStyle プロパティを使用して、選択された行のカスタムの背景を描画する方法を次のコード例に示します。変数 e の型が DataGridViewRowPrePaintEventArgs です。次のコード例は、「方法 : Windows フォームの DataGridView コントロールの行の外観をカスタマイズする」で示されている例の一部です。

' 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
// 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);
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridViewRowPrePaintEventArgs クラス
DataGridViewRowPrePaintEventArgs メンバ
System.Windows.Forms 名前空間
DataGridView クラス
DataGridView.RowPrePaint イベント
DataGridViewCellStyle クラス
DataGridViewRow クラス
DataGridViewRow.DefaultCellStyle プロパティ
その他の技術情報
Windows フォーム DataGridView コントロールを拡張するための推奨される手順



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

DataGridViewRowPrePaintEventArgs.InheritedRowStyle プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DataGridViewRowPrePaintEventArgs.InheritedRowStyle プロパティのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS