TableLayoutCellPaintEventArgs Class

 

Provides data for the CellPaint event.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

System.Object
  System.EventArgs
    System.Windows.Forms.PaintEventArgs
      System.Windows.Forms.TableLayoutCellPaintEventArgs

public class TableLayoutCellPaintEventArgs : PaintEventArgs

NameDescription
System_CAPS_pubmethodTableLayoutCellPaintEventArgs(Graphics, Rectangle, Rectangle, Int32, Int32)

Initializes a new instance of the TableLayoutCellPaintEventArgs class.

NameDescription
System_CAPS_pubpropertyCellBounds

Gets the size and location of the cell.

System_CAPS_pubpropertyClipRectangle

Gets the rectangle in which to paint.(Inherited from PaintEventArgs.)

System_CAPS_pubpropertyColumn

Gets the column of the cell.

System_CAPS_pubpropertyGraphics

Gets the graphics used to paint.(Inherited from PaintEventArgs.)

System_CAPS_pubpropertyRow

Gets the row of the cell.

NameDescription
System_CAPS_pubmethodDispose()

Releases all resources used by the PaintEventArgs.(Inherited from PaintEventArgs.)

System_CAPS_protmethodDispose(Boolean)

Releases the unmanaged resources used by the PaintEventArgs and optionally releases the managed resources.(Inherited from PaintEventArgs.)

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from PaintEventArgs.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

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

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

}

.NET Framework
Available since 2.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: