TableLayoutCellPaintEventArgs 类

定义

提供事件的数据 CellPaint

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 。 此代码示例是为控件提供的大型示例的 TableLayoutPanel 一部分。

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 类提供有关单元格的行、列和边界的信息,以支持在表格中绘制单元格。

构造函数

名称 说明
TableLayoutCellPaintEventArgs(Graphics, Rectangle, Rectangle, Int32, Int32)

初始化 TableLayoutCellPaintEventArgs 类的新实例。

属性

名称 说明
CellBounds

获取单元格的大小和位置。

ClipRectangle

获取要在其中绘制的矩形。

(继承自 PaintEventArgs)
Column

获取单元格的列。

Graphics

获取用于绘制的图形。

(继承自 PaintEventArgs)
Row

获取单元格的行。

方法

名称 说明
Dispose()

释放该 PaintEventArgs命令使用的所有资源。

(继承自 PaintEventArgs)
Dispose(Boolean)

释放由托管资源使用 PaintEventArgs 的非托管资源,并选择性地释放托管资源。

(继承自 PaintEventArgs)
Equals(Object)

确定指定的对象是否等于当前对象。

(继承自 Object)
GetHashCode()

用作默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)

显式接口实现

名称 说明
IDeviceContext.GetHdc()

返回 Windows 设备上下文的句柄。

(继承自 PaintEventArgs)
IDeviceContext.ReleaseHdc()

释放 Windows 设备上下文的句柄。

(继承自 PaintEventArgs)

适用于

另请参阅