DrawListViewItemEventArgs.DrawFocusRectangle 메서드

정의

포커스가 있을 경우 ListViewItem의 포커스 영역을 그립니다.

public:
 void DrawFocusRectangle();
public void DrawFocusRectangle ();
member this.DrawFocusRectangle : unit -> unit
Public Sub DrawFocusRectangle ()

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 DrawFocusRectangle 에 대 한 사용자 지정 그리기를 제공 하는 애플리케이션에서 메서드를 ListView 컨트롤입니다. 예에 대 한 처리기를 ListView.DrawItem 이벤트 전체 항목의 배경을 그립니다. 세부 정보 보기를 제외한 모든 보기에서이 처리기는 또한 전경 텍스트를 그립니다. 세부 정보 뷰에서 전경 텍스트를 그릴지를 ListView.DrawSubItem 이벤트입니다.

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

// Draws the backgrounds for entire ListView items.
private void listView1_DrawItem(object sender,
    DrawListViewItemEventArgs e)
{
    if ((e.State & ListViewItemStates.Selected) != 0)
    {
        // Draw the background and focus rectangle for a selected item.
        e.Graphics.FillRectangle(Brushes.Maroon, e.Bounds);
        e.DrawFocusRectangle();
    }
    else
    {
        // Draw the background for an unselected item.
        using (LinearGradientBrush brush =
            new LinearGradientBrush(e.Bounds, Color.Orange,
            Color.Maroon, LinearGradientMode.Horizontal))
        {
            e.Graphics.FillRectangle(brush, e.Bounds);
        }
    }

    // Draw the item text for views other than the Details view.
    if (listView1.View != View.Details)
    {
        e.DrawText();
    }
}
' Draws the backgrounds for entire ListView items.
Private Sub listView1_DrawItem(ByVal sender As Object, _
    ByVal e As DrawListViewItemEventArgs) _
    Handles listView1.DrawItem

    If Not (e.State And ListViewItemStates.Selected) = 0 Then

        ' Draw the background for a selected item.
        e.Graphics.FillRectangle(Brushes.Maroon, e.Bounds)
        e.DrawFocusRectangle()

    Else

        ' Draw the background for an unselected item.
        Dim brush As New LinearGradientBrush(e.Bounds, Color.Orange, _
            Color.Maroon, LinearGradientMode.Horizontal)
        Try
            e.Graphics.FillRectangle(brush, e.Bounds)
        Finally
            brush.Dispose()
        End Try

    End If

    ' Draw the item text for views other than the Details view.
    If Not Me.listView1.View = View.Details Then
        e.DrawText()
    End If

End Sub

설명

항목 둘레 표준 포커스 사각형을 그리려면이 메서드를 사용 합니다. 포커스 사각형에서 지정 된 영역 내에서 일반적으로 그려집니다는 Bounds 속성입니다. 그러나 컨트롤은 세부 정보 보기의 경우와 ListView.FullRowSelect 속성 값이 false, 포커스 사각형을 그릴지 기본 텍스트 영역 항목의 첫 번째 열에 대 한 합니다.

항목에 포커스가이 메서드를 호출 하기 전에 항목의 포커스 상태를 확인 해야 하는 경우에 포커스 사각형이 그려집니다.

적용 대상

추가 정보