DataGridViewCell.Paint メソッドとは? わかりやすく解説

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

DataGridViewCell.Paint メソッド

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

現在の DataGridViewCell描画ます。

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

Protected Overridable Sub
 Paint ( _
    graphics As Graphics, _
    clipBounds As Rectangle, _
    cellBounds As Rectangle, _
    rowIndex As Integer, _
    cellState As DataGridViewElementStates, _
    value As Object, _
    formattedValue As Object, _
    errorText As String, _
    cellStyle As DataGridViewCellStyle, _
    advancedBorderStyle As DataGridViewAdvancedBorderStyle, _
    paintParts As DataGridViewPaintParts _
)
Dim graphics As Graphics
Dim clipBounds As Rectangle
Dim cellBounds As Rectangle
Dim rowIndex As Integer
Dim cellState As DataGridViewElementStates
Dim value As Object
Dim formattedValue As Object
Dim errorText As String
Dim cellStyle As DataGridViewCellStyle
Dim advancedBorderStyle As DataGridViewAdvancedBorderStyle
Dim paintParts As DataGridViewPaintParts

Me.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState,
 value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts)
protected virtual void Paint (
    Graphics graphics,
    Rectangle clipBounds,
    Rectangle cellBounds,
    int rowIndex,
    DataGridViewElementStates cellState,
    Object value,
    Object formattedValue,
    string errorText,
    DataGridViewCellStyle cellStyle,
    DataGridViewAdvancedBorderStyle advancedBorderStyle,
    DataGridViewPaintParts paintParts
)
protected:
virtual void Paint (
    Graphics^ graphics, 
    Rectangle clipBounds, 
    Rectangle cellBounds, 
    int rowIndex, 
    DataGridViewElementStates cellState, 
    Object^ value, 
    Object^ formattedValue, 
    String^ errorText, 
    DataGridViewCellStyle^ cellStyle, 
    DataGridViewAdvancedBorderStyle^ advancedBorderStyle, 
    DataGridViewPaintParts paintParts
)
protected void Paint (
    Graphics graphics, 
    Rectangle clipBounds, 
    Rectangle cellBounds, 
    int rowIndex, 
    DataGridViewElementStates cellState, 
    Object value, 
    Object formattedValue, 
    String errorText, 
    DataGridViewCellStyle cellStyle, 
    DataGridViewAdvancedBorderStyle advancedBorderStyle, 
    DataGridViewPaintParts paintParts
)
protected function Paint (
    graphics : Graphics, 
    clipBounds : Rectangle, 
    cellBounds : Rectangle, 
    rowIndex : int, 
    cellState : DataGridViewElementStates, 
    value : Object, 
    formattedValue : Object, 
    errorText : String, 
    cellStyle : DataGridViewCellStyle, 
    advancedBorderStyle : DataGridViewAdvancedBorderStyle, 
    paintParts : DataGridViewPaintParts
)

パラメータ

graphics

DataGridViewCell の描画使用する Graphics

clipBounds

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

cellBounds

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

rowIndex

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

cellState

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

value

描画される DataGridViewCellデータ

formattedValue

描画される DataGridViewCell書式指定済みデータ

errorText

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

cellStyle

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

advancedBorderStyle

描画されるセル境界線スタイル格納された DataGridViewAdvancedBorderStyle。

paintParts

セルのどの部分描画する必要があるのかを指定する、DataGridViewPaintParts 値のビットごとの組み合わせ

使用例使用例

DataGridViewButtonCell の Paint メソッドオーバーライドする方法次のコード例示します次のコード例は、「方法 : Windows フォーム DataGridView コントロールボタン列にあるボタン無効にする」で示されている例の一部です。

Protected Overrides Sub
 Paint(ByVal graphics As Graphics, _
    ByVal clipBounds As Rectangle, ByVal
 cellBounds As Rectangle, _
    ByVal rowIndex As Integer,
 _
    ByVal elementState As DataGridViewElementStates,
 _
    ByVal value As Object,
 ByVal formattedValue As Object,
 _
    ByVal errorText As String,
 _
    ByVal cellStyle As DataGridViewCellStyle,
 _
    ByVal advancedBorderStyle As DataGridViewAdvancedBorderStyle,
 _
    ByVal paintParts As DataGridViewPaintParts)

    ' The button cell is disabled, so paint the border,  
    ' background, and disabled button for the cell.
    If Not Me.enabledValue
 Then

        ' Draw the background of the cell, if specified.
        If (paintParts And DataGridViewPaintParts.Background)
 = _
            DataGridViewPaintParts.Background Then

            Dim cellBackground As New
 SolidBrush(cellStyle.BackColor)
            graphics.FillRectangle(cellBackground, cellBounds)
            cellBackground.Dispose()
        End If

        ' Draw the cell borders, if specified.
        If (paintParts And DataGridViewPaintParts.Border)
 = _
            DataGridViewPaintParts.Border Then

            PaintBorder(graphics, clipBounds, cellBounds, cellStyle, _
                advancedBorderStyle)
        End If

        ' Calculate the area in which to draw the button.
        Dim buttonArea As Rectangle = cellBounds
        Dim buttonAdjustment As Rectangle =
 _
            Me.BorderWidths(advancedBorderStyle)
        buttonArea.X += buttonAdjustment.X
        buttonArea.Y += buttonAdjustment.Y
        buttonArea.Height -= buttonAdjustment.Height
        buttonArea.Width -= buttonAdjustment.Width

        ' Draw the disabled button.                
        ButtonRenderer.DrawButton(graphics, buttonArea, _
            PushButtonState.Disabled)

        ' Draw the disabled button text. 
        If TypeOf Me.FormattedValue
 Is String Then
            TextRenderer.DrawText(graphics, CStr(Me.FormattedValue),
 _
                Me.DataGridView.Font, buttonArea, SystemColors.GrayText)
        End If

    Else
        ' The button cell is enabled, so let the base class 
        ' handle the painting.
        MyBase.Paint(graphics, clipBounds, cellBounds, rowIndex,
 _
            elementState, value, formattedValue, errorText, _
            cellStyle, advancedBorderStyle, paintParts)
    End If
End Sub
protected override void Paint(Graphics graphics
,
    Rectangle clipBounds, Rectangle cellBounds, int rowIndex,
    DataGridViewElementStates elementState, object value,
    object formattedValue, string errorText,
    DataGridViewCellStyle cellStyle,
    DataGridViewAdvancedBorderStyle advancedBorderStyle,
    DataGridViewPaintParts paintParts)
{
    // The button cell is disabled, so paint the border,  
    // background, and disabled button for the cell.
    if (!this.enabledValue)
    {
        // Draw the cell background, if specified.
        if ((paintParts & DataGridViewPaintParts.Background)
 ==
            DataGridViewPaintParts.Background)
        {
            SolidBrush cellBackground =
                new SolidBrush(cellStyle.BackColor);
            graphics.FillRectangle(cellBackground, cellBounds);
            cellBackground.Dispose();
        }

        // Draw the cell borders, if specified.
        if ((paintParts & DataGridViewPaintParts.Border) ==
            DataGridViewPaintParts.Border)
        {
            PaintBorder(graphics, clipBounds, cellBounds, cellStyle,
                advancedBorderStyle);
        }

        // Calculate the area in which to draw the button.
        Rectangle buttonArea = cellBounds;
        Rectangle buttonAdjustment =
            this.BorderWidths(advancedBorderStyle);
        buttonArea.X += buttonAdjustment.X;
        buttonArea.Y += buttonAdjustment.Y;
        buttonArea.Height -= buttonAdjustment.Height;
        buttonArea.Width -= buttonAdjustment.Width;

        // Draw the disabled button.                
        ButtonRenderer.DrawButton(graphics, buttonArea,
            PushButtonState.Disabled);

        // Draw the disabled button text. 
        if (this.FormattedValue is String)
 
        {
            TextRenderer.DrawText(graphics,
                (string)this.FormattedValue
,
                this.DataGridView.Font,
                buttonArea, SystemColors.GrayText);
        }
    }
    else
    {
        // The button cell is enabled, so let the base class 
        // handle the painting.
        base.Paint(graphics, clipBounds, cellBounds, rowIndex
,
            elementState, value, formattedValue, errorText,
            cellStyle, advancedBorderStyle, paintParts);
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridViewCell クラス
DataGridViewCell メンバ
System.Windows.Forms 名前空間
DataGridView クラス
Control.Paint イベント
PaintBorder
System.Drawing.Graphics
System.Drawing.Rectangle
DataGridViewElementStates
DataGridViewCellStyle
DataGridViewAdvancedBorderStyle クラス


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

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

辞書ショートカット

すべての辞書の索引

「DataGridViewCell.Paint メソッド」の関連用語

DataGridViewCell.Paint メソッドのお隣キーワード
検索ランキング

   

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



DataGridViewCell.Paint メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS