DataGridViewRowPrePaintEventArgs クラス
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


RowPrePaint イベントは、行が DataGridView コントロール上に描画される前に発生します。RowPrePaint を使用すると、行内のセルが描画される前に、行の外観を手動で調整できます。これは、1 つの列の内容が複数の列にまたがる行の作成など、行をカスタマイズする場合に便利です。DataGridView の行に直接アクセスせずに行の設定を取得するには、DataGridViewRowPrePaintEventArgs のプロパティを使用します。

RowPrePaint イベントを処理して、選択されたセルのカスタムの背景を描画する方法を次のコード例に示します。次のコード例は、「方法 : Windows フォームの DataGridView コントロールの行の外観をカスタマイズする」で示されている例の一部です。
' Paints the custom selection background for selected rows. Sub dataGridView1_RowPrePaint(ByVal sender As Object, _ ByVal e As DataGridViewRowPrePaintEventArgs) _ Handles dataGridView1.RowPrePaint ' Do not automatically paint the focus rectangle. e.PaintParts = e.PaintParts And Not DataGridViewPaintParts.Focus ' 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 End Sub 'dataGridView1_RowPrePaint
// Paints the custom selection background for selected rows. void dataGridView1_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e) { // Do not automatically paint the focus rectangle. e.PaintParts &= ~DataGridViewPaintParts.Focus; // 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); } } }

System.EventArgs
System.ComponentModel.HandledEventArgs
System.Windows.Forms.DataGridViewRowPrePaintEventArgs


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DataGridViewRowPrePaintEventArgs コンストラクタ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Public Sub New ( _ dataGridView As DataGridView, _ graphics As Graphics, _ clipBounds As Rectangle, _ rowBounds As Rectangle, _ rowIndex As Integer, _ rowState As DataGridViewElementStates, _ errorText As String, _ inheritedRowStyle As DataGridViewCellStyle, _ isFirstDisplayedRow As Boolean, _ isLastVisibleRow As Boolean _ )
Dim dataGridView As DataGridView Dim graphics As Graphics Dim clipBounds As Rectangle Dim rowBounds As Rectangle Dim rowIndex As Integer Dim rowState As DataGridViewElementStates Dim errorText As String Dim inheritedRowStyle As DataGridViewCellStyle Dim isFirstDisplayedRow As Boolean Dim isLastVisibleRow As Boolean Dim instance As New DataGridViewRowPrePaintEventArgs(dataGridView, graphics, clipBounds, rowBounds, rowIndex, rowState, errorText, inheritedRowStyle, isFirstDisplayedRow, isLastVisibleRow)
public DataGridViewRowPrePaintEventArgs ( DataGridView dataGridView, Graphics graphics, Rectangle clipBounds, Rectangle rowBounds, int rowIndex, DataGridViewElementStates rowState, string errorText, DataGridViewCellStyle inheritedRowStyle, bool isFirstDisplayedRow, bool isLastVisibleRow )
public: DataGridViewRowPrePaintEventArgs ( DataGridView^ dataGridView, Graphics^ graphics, Rectangle clipBounds, Rectangle rowBounds, int rowIndex, DataGridViewElementStates rowState, String^ errorText, DataGridViewCellStyle^ inheritedRowStyle, bool isFirstDisplayedRow, bool isLastVisibleRow )
public DataGridViewRowPrePaintEventArgs ( DataGridView dataGridView, Graphics graphics, Rectangle clipBounds, Rectangle rowBounds, int rowIndex, DataGridViewElementStates rowState, String errorText, DataGridViewCellStyle inheritedRowStyle, boolean isFirstDisplayedRow, boolean isLastVisibleRow )
public function DataGridViewRowPrePaintEventArgs ( dataGridView : DataGridView, graphics : Graphics, clipBounds : Rectangle, rowBounds : Rectangle, rowIndex : int, rowState : DataGridViewElementStates, errorText : String, inheritedRowStyle : DataGridViewCellStyle, isFirstDisplayedRow : boolean, isLastVisibleRow : boolean )

例外の種類 | 条件 |
---|---|
ArgumentNullException | dataGridView が null 参照 (Visual Basic では Nothing) です。 または graphics が null 参照 (Visual Basic では Nothing) です。 または inheritedRowStyle が null 参照 (Visual Basic では Nothing) です。 |

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DataGridViewRowPrePaintEventArgs プロパティ

名前 | 説明 | |
---|---|---|
![]() | ClipBounds | 再描画が必要な DataGridView の領域を取得または設定します。 |
![]() | ErrorText | 現在の DataGridViewRow のエラー メッセージを表す文字列を取得します。 |
![]() | Graphics | 現在の DataGridViewRow の描画に使用される Graphics を取得します。 |
![]() | Handled | イベント ハンドラがイベントを完全に処理したかどうか、またはシステムが独自の処理を継続する必要があるかどうかを示す値を取得または設定します。 ( HandledEventArgs から継承されます。) |
![]() | InheritedRowStyle | 行に適用されるセル スタイルを取得します。 |
![]() | IsFirstDisplayedRow | 現在の行が、DataGridView に現在表示されている最初の行かどうかを示す値を取得します。 |
![]() | IsLastVisibleRow | 現在の行が DataGridView に表示される最後の行かどうかを示す値を取得します。 |
![]() | PaintParts | 描画されるセル部分。 |
![]() | RowBounds | 現在の DataGridViewRow の境界を取得します。 |
![]() | RowIndex | 現在の DataGridViewRow のインデックスを取得します。 |
![]() | State | 現在の DataGridViewRow の状態を取得します。 |

関連項目
DataGridViewRowPrePaintEventArgs クラスSystem.Windows.Forms 名前空間
DataGridView クラス
DataGridView.RowPrePaint イベント
DataGridViewRowPrePaintEventArgs メソッド

名前 | 説明 | |
---|---|---|
![]() | DrawFocus | 指定した境界の周囲にフォーカスを表す四角形を描画します。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | PaintCells | 指定した境界内の領域に対応する指定したセルの部分を描画します。 |
![]() | PaintCellsBackground | 指定した境界内の領域に対応するセルの背景を描画します。 |
![]() | PaintCellsContent | 指定した境界内の領域に対応するセルの内容を描画します。 |
![]() | PaintHeader | オーバーロードされます。 現在の行の行ヘッダーを描画します。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

関連項目
DataGridViewRowPrePaintEventArgs クラスSystem.Windows.Forms 名前空間
DataGridView クラス
DataGridView.RowPrePaint イベント
DataGridViewRowPrePaintEventArgs メンバ
DataGridViewRowPrePaintEventArgs データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | ClipBounds | 再描画が必要な DataGridView の領域を取得または設定します。 |
![]() | ErrorText | 現在の DataGridViewRow のエラー メッセージを表す文字列を取得します。 |
![]() | Graphics | 現在の DataGridViewRow の描画に使用される Graphics を取得します。 |
![]() | Handled | イベント ハンドラがイベントを完全に処理したかどうか、またはシステムが独自の処理を継続する必要があるかどうかを示す値を取得または設定します。(HandledEventArgs から継承されます。) |
![]() | InheritedRowStyle | 行に適用されるセル スタイルを取得します。 |
![]() | IsFirstDisplayedRow | 現在の行が、DataGridView に現在表示されている最初の行かどうかを示す値を取得します。 |
![]() | IsLastVisibleRow | 現在の行が DataGridView に表示される最後の行かどうかを示す値を取得します。 |
![]() | PaintParts | 描画されるセル部分。 |
![]() | RowBounds | 現在の DataGridViewRow の境界を取得します。 |
![]() | RowIndex | 現在の DataGridViewRow のインデックスを取得します。 |
![]() | State | 現在の DataGridViewRow の状態を取得します。 |

名前 | 説明 | |
---|---|---|
![]() | DrawFocus | 指定した境界の周囲にフォーカスを表す四角形を描画します。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | PaintCells | 指定した境界内の領域に対応する指定したセルの部分を描画します。 |
![]() | PaintCellsBackground | 指定した境界内の領域に対応するセルの背景を描画します。 |
![]() | PaintCellsContent | 指定した境界内の領域に対応するセルの内容を描画します。 |
![]() | PaintHeader | オーバーロードされます。 現在の行の行ヘッダーを描画します。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

関連項目
DataGridViewRowPrePaintEventArgs クラスSystem.Windows.Forms 名前空間
DataGridView クラス
DataGridView.RowPrePaint イベント
Weblioに収録されているすべての辞書からDataGridViewRowPrePaintEventArgsを検索する場合は、下記のリンクをクリックしてください。

- DataGridViewRowPrePaintEventArgsのページへのリンク