DrawListViewColumnHeaderEventArgs.Bounds 속성

정의

그릴 열 머리글의 크기와 위치를 가져옵니다.

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

속성 값

열 머리글의 범위를 나타내는 Rectangle입니다.

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 Bounds 속성에 대 한 사용자 지정 그리기 기능을 제공 하는 애플리케이션에는 ListView 컨트롤입니다.

전체 예제를 참조 하세요.를 DrawListViewColumnHeaderEventArgs 개요 항목을 참조 합니다.

// Draws column headers.
private void listView1_DrawColumnHeader(object sender,
    DrawListViewColumnHeaderEventArgs e)
{
    using (StringFormat sf = new StringFormat())
    {
        // Store the column text alignment, letting it default
        // to Left if it has not been set to Center or Right.
        switch (e.Header.TextAlign)
        {
            case HorizontalAlignment.Center:
                sf.Alignment = StringAlignment.Center;
                break;
            case HorizontalAlignment.Right:
                sf.Alignment = StringAlignment.Far;
                break;
        }

        // Draw the standard header background.
        e.DrawBackground();

        // Draw the header text.
        using (Font headerFont =
                    new Font("Helvetica", 10, FontStyle.Bold))
        {
            e.Graphics.DrawString(e.Header.Text, headerFont,
                Brushes.Black, e.Bounds, sf);
        }
    }
    return;
}
' Draws column headers.
Private Sub listView1_DrawColumnHeader(ByVal sender As Object, _
    ByVal e As DrawListViewColumnHeaderEventArgs) _
    Handles listView1.DrawColumnHeader

    Dim sf As New StringFormat()
    Try

        ' Store the column text alignment, letting it default
        ' to Left if it has not been set to Center or Right.
        Select Case e.Header.TextAlign
            Case HorizontalAlignment.Center
                sf.Alignment = StringAlignment.Center
            Case HorizontalAlignment.Right
                sf.Alignment = StringAlignment.Far
        End Select

        ' Draw the standard header background.
        e.DrawBackground()

        ' Draw the header text.
        Dim headerFont As New Font("Helvetica", 10, FontStyle.Bold)
        Try
            e.Graphics.DrawString(e.Header.Text, headerFont, _
                Brushes.Black, e.Bounds, sf)
        Finally
            headerFont.Dispose()
        End Try

    Finally
        sf.Dispose()
    End Try

End Sub

설명

이 속성에 지정 된 위치가의 왼쪽 위 모퉁이 기준으로 ListView 제어 합니다.

적용 대상

추가 정보