TableLayoutCellPaintEventHandler Delegát

Definice

Představuje metodu, která bude zpracovávat CellPaint událost.

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)

Parametry

sender
Object

Zdroj události

e
TableLayoutCellPaintEventArgs

A TableLayoutCellPaintEventArgs , který obsahuje data události.

Příklady

Následující příklad ukazuje, jak TableLayoutCellPaintEventHandler delegát přizpůsobit vzhled TableLayoutPanel ovládacího prvku. Tento příklad kódu je součástí většího příkladu TableLayoutPanel pro ovládací prvek.

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

Poznámky

Při vytváření delegáta TableLayoutCellPaintEventHandler identifikujete metodu pro zpracování události. Pokud chcete událost přidružit k obslužné rutině události, přidejte do události instanci delegáta. Obslužná rutina události je volána při každém výskytu události, dokud neodeberete delegáta. Další informace o delegátech obslužných rutin událostí najdete v tématu Zpracování a vyvolávání událostí.

Metody rozšíření

GetMethodInfo(Delegate)

Získá objekt, který představuje metodu reprezentovanou zadaným delegátem.

Platí pro

Viz také