TableLayoutCellPaintEventHandler 代理人

定義

CellPaint イベントを処理するメソッドを表します。

public delegate void TableLayoutCellPaintEventHandler(System::Object ^ sender, TableLayoutCellPaintEventArgs ^ e);
public delegate void TableLayoutCellPaintEventHandler(object sender, TableLayoutCellPaintEventArgs e);
public delegate void TableLayoutCellPaintEventHandler(object? sender, TableLayoutCellPaintEventArgs e);
type TableLayoutCellPaintEventHandler = delegate of obj * TableLayoutCellPaintEventArgs -> unit
Public Delegate Sub TableLayoutCellPaintEventHandler(sender As Object, e As TableLayoutCellPaintEventArgs)

パラメーター

sender
Object

イベントのソース。

e
TableLayoutCellPaintEventArgs

イベント データを格納している TableLayoutCellPaintEventArgs

次の例では、デリゲートを TableLayoutCellPaintEventHandler 使用してコントロールの外観をカスタマイズする方法を TableLayoutPanel 示します。 このコード例は、 コントロールに対して提供されるより大きな例の TableLayoutPanel 一部です。

public class DemoTableLayoutPanel : TableLayoutPanel
{
    protected override void OnCellPaint(TableLayoutCellPaintEventArgs e)
    {
        base.OnCellPaint(e);

        Control c = this.GetControlFromPosition(e.Column, e.Row);

        if ( c != null )
        {
            Graphics g = e.Graphics;

            g.DrawRectangle(
                Pens.Red, 
                e.CellBounds.Location.X+1,
                e.CellBounds.Location.Y + 1,
                e.CellBounds.Width - 2, e.CellBounds.Height - 2);

            g.FillRectangle(
                Brushes.Blue, 
                e.CellBounds.Location.X + 1, 
                e.CellBounds.Location.Y + 1, 
                e.CellBounds.Width - 2, 
                e.CellBounds.Height - 2);
        };
    }
}
Public Class DemoTableLayoutPanel
    Inherits TableLayoutPanel

    Protected Overrides Sub OnCellPaint( _
    ByVal e As System.Windows.Forms.TableLayoutCellPaintEventArgs)

        MyBase.OnCellPaint(e)

        Dim c As Control = Me.GetControlFromPosition(e.Column, e.Row)

        If c IsNot Nothing Then
            Dim g As Graphics = e.Graphics

            g.DrawRectangle( _
            Pens.Red, _
            e.CellBounds.Location.X + 1, _
            e.CellBounds.Location.Y + 1, _
            e.CellBounds.Width - 2, _
            e.CellBounds.Height - 2)

            g.FillRectangle( _
            Brushes.Blue, _
            e.CellBounds.Location.X + 1, _
            e.CellBounds.Location.Y + 1, _
            e.CellBounds.Width - 2, _
            e.CellBounds.Height - 2)
        End If

    End Sub

End Class

注釈

デリゲートを TableLayoutCellPaintEventHandler 作成するときは、イベントを処理するメソッドを識別します。 イベント ハンドラーにイベントを関連付けるには、イベントにデリゲートのインスタンスを追加します。 イベント ハンドラーは、デリゲートを削除しない限り、イベントが発生するたびに呼び出されます。 イベント ハンドラー デリゲートの詳細については、「イベントの 処理と発生」を参照してください。

拡張メソッド

GetMethodInfo(Delegate)

指定したデリゲートによって表されるメソッドを表すオブジェクトを取得します。

適用対象

こちらもご覧ください