TableLayoutCellPaintEventArgs 类

定义

CellPaint 事件提供数据。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
继承
TableLayoutCellPaintEventArgs

示例

下面的示例演示如何TableLayoutCellPaintEventArgs自定义TableLayoutPanel控件的外观。The following example shows how to a TableLayoutCellPaintEventArgs to customize the appearance of a TableLayoutPanel control. 此代码示例是为TableLayoutPanel控件提供的更大示例的一部分。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

注解

TableLayoutCellPaintEventArgs类提供有关单元格的行、列和边界的信息, 以支持在表中绘制单元格。The TableLayoutCellPaintEventArgs class provides information about the row, column, and bounds of the cell to support painting of the cell in the table.

构造函数

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

初始化 TableLayoutCellPaintEventArgs 类的新实例。Initializes a new instance of the TableLayoutCellPaintEventArgs class.

属性

CellBounds

获取该单元格的大小和位置。Gets the size and location of the cell.

ClipRectangle

获取要在其中进行绘画的矩形。Gets the rectangle in which to paint.

(继承自 PaintEventArgs)
Column

获取该单元格的列。Gets the column of the cell.

Graphics

获取用于进行绘制的图形。Gets the graphics used to paint.

(继承自 PaintEventArgs)
Row

获取该单元格的行。Gets the row of the cell.

方法

Dispose()

释放由 PaintEventArgs 使用的所有资源。Releases all resources used by the PaintEventArgs.

(继承自 PaintEventArgs)
Dispose(Boolean)

释放由 PaintEventArgs 占用的非托管资源,还可以另外再释放托管资源。Releases the unmanaged resources used by the PaintEventArgs and optionally releases the managed resources.

(继承自 PaintEventArgs)
Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅