TableLayoutCellPaintEventArgs TableLayoutCellPaintEventArgs TableLayoutCellPaintEventArgs TableLayoutCellPaintEventArgs Class

定义

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
继承
TableLayoutCellPaintEventArgsTableLayoutCellPaintEventArgsTableLayoutCellPaintEventArgsTableLayoutCellPaintEventArgs

示例

下面的示例演示如何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(Graphics, Rectangle, Rectangle, Int32, Int32) TableLayoutCellPaintEventArgs(Graphics, Rectangle, Rectangle, Int32, Int32) TableLayoutCellPaintEventArgs(Graphics, Rectangle, Rectangle, Int32, Int32)

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

属性

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.

方法

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

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

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

释放由 PaintEventArgs 占用的非托管资源,还可以另外再释放托管资源。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()

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

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

创建当前 Object 的浅表副本。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)

适用于

另请参阅