DrawListViewItemEventArgs.State 속성

정의

그릴 ListViewItem의 현재 상태를 가져옵니다.

public:
 property System::Windows::Forms::ListViewItemStates State { System::Windows::Forms::ListViewItemStates get(); };
public System.Windows.Forms.ListViewItemStates State { get; }
member this.State : System.Windows.Forms.ListViewItemStates
Public ReadOnly Property State As ListViewItemStates

속성 값

ListViewItemStates의 현재 상태를 나타내는 ListViewItem 값의 비트 조합입니다.

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 State 속성에 대 한 사용자 지정 그리기 기능을 제공 하는 애플리케이션에는 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

설명

이 속성을 사용 하 여 확인 여부를 ListViewItem 그릴 특정 상태입니다. 이 속성 항목에 대 한 기본 상태 정보를 제공합니다. 항목 선택, 옵션을 선택 또는 초점을 맞춘 확인 하려면 예를 들어,이 속성을 사용할 수 있습니다. 자세한 해야 할 경우 통해 항목을 검색 합니다 Item 속성 및 해당 속성을 직접 확인 합니다.

적용 대상

추가 정보