Breyta

Deila með


TableLayoutCellPaintEventArgs Class

Definition

Provides data for the CellPaint event.

public ref class TableLayoutCellPaintEventArgs : System::Windows::Forms::PaintEventArgs
public class TableLayoutCellPaintEventArgs : System.Windows.Forms.PaintEventArgs
type TableLayoutCellPaintEventArgs = class
    inherit PaintEventArgs
Public Class TableLayoutCellPaintEventArgs
Inherits PaintEventArgs
Inheritance
TableLayoutCellPaintEventArgs

Examples

The following example shows how to a TableLayoutCellPaintEventArgs to customize the appearance of a TableLayoutPanel control. This code example is part of a larger example provided for the TableLayoutPanel control.

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

Remarks

The TableLayoutCellPaintEventArgs class provides information about the row, column, and bounds of the cell to support painting of the cell in the table.

Constructors

TableLayoutCellPaintEventArgs(Graphics, Rectangle, Rectangle, Int32, Int32)

Initializes a new instance of the TableLayoutCellPaintEventArgs class.

Properties

CellBounds

Gets the size and location of the cell.

ClipRectangle

Gets the rectangle in which to paint.

(Inherited from PaintEventArgs)
Column

Gets the column of the cell.

Graphics

Gets the graphics used to paint.

(Inherited from PaintEventArgs)
Row

Gets the row of the cell.

Methods

Dispose()

Releases all resources used by the PaintEventArgs.

(Inherited from PaintEventArgs)
Dispose(Boolean)

Releases the unmanaged resources used by the PaintEventArgs and optionally releases the managed resources.

(Inherited from PaintEventArgs)
Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations

IDeviceContext.GetHdc()

Returns the handle to a Windows device context.

(Inherited from PaintEventArgs)
IDeviceContext.ReleaseHdc()

Releases the handle of a Windows device context.

(Inherited from PaintEventArgs)

Applies to

See also