DataGridViewPaintParts 列挙体とは? わかりやすく解説

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

DataGridViewPaintParts 列挙体

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

描画される DataGridViewCell の部分指定するための値を定義します

この列挙体には、メンバ値のビットごとの組み合わせ可能にする FlagsAttribute 属性含まれています。

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

<FlagsAttribute> _
Public Enumeration DataGridViewPaintParts
Dim instance As DataGridViewPaintParts
[FlagsAttribute] 
public enum DataGridViewPaintParts
[FlagsAttribute] 
public enum class DataGridViewPaintParts
/** @attribute FlagsAttribute() */ 
public enum DataGridViewPaintParts
FlagsAttribute 
public enum DataGridViewPaintParts
メンバメンバ
 メンバ説明
Allセルすべての部分描画する必要があります。 
Backgroundセル背景描画する必要があります。 
Borderセル境界線描画する必要があります。 
ContentBackgroundセル内容背景描画する必要があります。 
ContentForegroundセル内容前景描画する必要があります。 
ErrorIconセルエラー アイコン描画する必要があります。 
Focusセル周囲フォーカスを示す四角形描画する必要があります。 
None何も描画しません。 
SelectionBackgroundセル選択されたときに、セル背景描画する必要があります。 
解説解説

この列挙体は、プロテクト メソッド DataGridViewCell.Paint によって使用されるほか、DataGridView コントロールの CellPainting、RowPrePaint および RowPostPaint の各イベント用のハンドラでも使用されます。

使用例使用例

この型の使用方法次のコード例示します次の例は「方法 : 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.Windows.Forms 名前空間
DataGridView クラス
DataGridView.CellPainting イベント
DataGridView.RowPrePaint イベント
DataGridView.RowPostPaint イベント
DataGridViewCell クラス
DataGridViewCell.Paint



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

辞書ショートカット

すべての辞書の索引

「DataGridViewPaintParts 列挙体」の関連用語

DataGridViewPaintParts 列挙体のお隣キーワード
検索ランキング

   

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



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

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

©2025 GRAS Group, Inc.RSS