Lire en anglais

Partager via


TableLayoutCellPaintEventHandler Délégué

Définition

Représente la méthode qui gérera l'événement CellPaint.

C#
public delegate void TableLayoutCellPaintEventHandler(object sender, TableLayoutCellPaintEventArgs e);
C#
public delegate void TableLayoutCellPaintEventHandler(object? sender, TableLayoutCellPaintEventArgs e);

Paramètres

sender
Object

Source de l'événement.

e
TableLayoutCellPaintEventArgs

TableLayoutCellPaintEventArgs qui contient les données d’événement.

Exemples

L’exemple suivant montre comment un TableLayoutCellPaintEventHandler délégué pour personnaliser l’apparence d’un TableLayoutPanel contrôle. Cet exemple de code fait partie d’un exemple plus grand fourni pour le TableLayoutPanel contrôle.

C#
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);
        };
    }
}

Remarques

Lorsque vous créez un TableLayoutCellPaintEventHandler délégué, vous identifiez une méthode pour gérer l’événement. Pour associer l'événement au gestionnaire d'événements, ajoutez une instance du délégué à l'événement. Le gestionnaire d'événements est appelé chaque fois qu'un événement se produit, sauf si vous supprimez le délégué. Pour plus d’informations sur les délégués de gestionnaires d’événements, consultez Gestion et déclenchement d’événements.

Méthodes d’extension

GetMethodInfo(Delegate)

Obtient un objet qui représente la méthode représentée par le délégué spécifié.

S’applique à

Produit Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Voir aussi