DataGridViewRowPrePaintEventArgsとは? わかりやすく解説

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

DataGridViewRowPrePaintEventArgs クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

RowPrePaint イベントデータ提供します

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

Public Class DataGridViewRowPrePaintEventArgs
    Inherits HandledEventArgs
Dim instance As DataGridViewRowPrePaintEventArgs
public class DataGridViewRowPrePaintEventArgs
 : HandledEventArgs
public ref class DataGridViewRowPrePaintEventArgs
 : public HandledEventArgs
public class DataGridViewRowPrePaintEventArgs
 extends HandledEventArgs
public class DataGridViewRowPrePaintEventArgs
 extends HandledEventArgs
解説解説

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.Object
   System.EventArgs
     System.ComponentModel.HandledEventArgs
      System.Windows.Forms.DataGridViewRowPrePaintEventArgs
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridViewRowPrePaintEventArgs メンバ
System.Windows.Forms 名前空間
DataGridView クラス
DataGridView.RowPrePaint イベント

DataGridViewRowPrePaintEventArgs コンストラクタ

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

DataGridViewRowPrePaintEventArgs クラス新しインスタンス初期化します。

名前空間: System.Windows.Forms
アセンブリ: 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
)

パラメータ

dataGridView

描画される行を所有する DataGridView。

graphics

DataGridViewRow の描画使用する Graphics

clipBounds

描画必要な DataGridView領域を表す Rectangle

rowBounds

描画される DataGridViewRow境界格納されRectangle

rowIndex

描画されるセルの行インデックス

rowState

行の状態を指定する DataGridViewElementStates 値のビットごとの組み合わせ

errorText

行に関連付けられたエラー メッセージ

inheritedRowStyle

に関する書式スタイル情報格納された DataGridViewCellStyle。

isFirstDisplayedRow

現在の行が、現在 DataGridView表示されている最初の行かどうかを示す場合trueそれ以外場合false

isLastVisibleRow

現在の行が、Visible プロパティtrue設定された、DataGridView最後の行かどうかを示す場合trueそれ以外場合false

例外例外
例外種類条件

ArgumentNullException

dataGridViewnull 参照 (Visual Basic では Nothing) です。

または

graphicsnull 参照 (Visual Basic では Nothing) です。

または

inheritedRowStylenull 参照 (Visual Basic では Nothing) です。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridViewRowPrePaintEventArgs クラス
DataGridViewRowPrePaintEventArgs メンバ
System.Windows.Forms 名前空間
DataGridView クラス
Graphics
Rectangle
DataGridViewRow クラス
DataGridViewElementStates 列挙
DataGridViewCellStyle クラス

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 メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
参照参照

関連項目

DataGridViewRowPrePaintEventArgs クラス
System.Windows.Forms 名前空間
DataGridView クラス
DataGridView.RowPrePaint イベント

DataGridViewRowPrePaintEventArgs メンバ

RowPrePaint イベントデータ提供します

DataGridViewRowPrePaintEventArgs データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド DataGridViewRowPrePaintEventArgs 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 イベント


このページでは「.NET Framework クラス ライブラリ リファレンス」からDataGridViewRowPrePaintEventArgsを検索した結果を表示しています。
Weblioに収録されているすべての辞書からDataGridViewRowPrePaintEventArgsを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からDataGridViewRowPrePaintEventArgs を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「DataGridViewRowPrePaintEventArgs」の関連用語

DataGridViewRowPrePaintEventArgsのお隣キーワード
検索ランキング

   

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



DataGridViewRowPrePaintEventArgsのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS