다음을 통해 공유


TableLayoutCellPaintEventArgs.CellBounds 속성

정의

셀의 크기와 위치를 가져옵니다.

public:
 property System::Drawing::Rectangle CellBounds { System::Drawing::Rectangle get(); };
public System.Drawing.Rectangle CellBounds { get; }
member this.CellBounds : System.Drawing.Rectangle
Public ReadOnly Property CellBounds As Rectangle

속성 값

Rectangle

셀의 크기와 위치를 나타내는 Rectangle입니다.

예제

다음 예제와 방법을 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

적용 대상

추가 정보