TableLayoutCellPaintEventHandler Delegat

Definicja

Reprezentuje metodę, która będzie obsługiwać CellPaint zdarzenie.

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

Źródło zdarzenia.

e
TableLayoutCellPaintEventArgs

Element TableLayoutCellPaintEventArgs zawierający dane zdarzenia.

Przykłady

W poniższym przykładzie pokazano, jak TableLayoutCellPaintEventHandler delegat dostosować wygląd kontrolki TableLayoutPanel . Ten przykład kodu jest częścią większego przykładu udostępnionego dla kontrolki 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

Uwagi

Podczas tworzenia delegata należy zidentyfikować metodę TableLayoutCellPaintEventHandler do obsługi zdarzenia. Aby skojarzyć zdarzenie z programem obsługi zdarzeń, dodaj wystąpienie delegata do zdarzenia. Program obsługi zdarzeń jest wywoływany przy każdym wystąpieniu zdarzenia, o ile nie usunięto delegata. Aby uzyskać więcej informacji na temat delegatów programu obsługi zdarzeń, zobacz Obsługa i podnoszenie zdarzeń.

Metody rozszerzania

GetMethodInfo(Delegate)

Pobiera obiekt reprezentujący metodę reprezentowaną przez określonego delegata.

Dotyczy

Zobacz też