TableLayoutCellPaintEventArgs TableLayoutCellPaintEventArgs TableLayoutCellPaintEventArgs 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
TableLayoutCellPaintEventArgsTableLayoutCellPaintEventArgsTableLayoutCellPaintEventArgsTableLayoutCellPaintEventArgs

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) TableLayoutCellPaintEventArgs(Graphics, Rectangle, Rectangle, Int32, Int32) TableLayoutCellPaintEventArgs(Graphics, Rectangle, Rectangle, Int32, Int32) TableLayoutCellPaintEventArgs(Graphics, Rectangle, Rectangle, Int32, Int32)

Initializes a new instance of the TableLayoutCellPaintEventArgs class.

Properties

CellBounds CellBounds CellBounds CellBounds

Gets the size and location of the cell.

ClipRectangle ClipRectangle ClipRectangle ClipRectangle

Gets the rectangle in which to paint.

(Inherited from PaintEventArgs)
Column Column Column Column

Gets the column of the cell.

Graphics Graphics Graphics Graphics

Gets the graphics used to paint.

(Inherited from PaintEventArgs)
Row Row Row Row

Gets the row of the cell.

Methods

Dispose() Dispose() Dispose() Dispose()

Releases all resources used by the PaintEventArgs.

(Inherited from PaintEventArgs)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

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

(Inherited from PaintEventArgs)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

See also