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 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。

(繼承來源 PaintEventArgs)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

IDeviceContext.GetHdc()

傳回 Windows 裝置內容的控制代碼。

(繼承來源 PaintEventArgs)
IDeviceContext.ReleaseHdc()

釋放 Windows 裝置內容的控制代碼。

(繼承來源 PaintEventArgs)

適用於

另請參閱