ListViewItemStates 열거형

정의

ListViewItem의 가능한 상태를 나타내는 상수를 정의합니다.

이 열거형은 멤버 값의 비트 조합을 지원합니다.

public enum class ListViewItemStates
[System.Flags]
public enum ListViewItemStates
[<System.Flags>]
type ListViewItemStates = 
Public Enum ListViewItemStates
상속
ListViewItemStates
특성

필드

Checked 8

항목이 선택되어 있습니다.

Default 32

항목이 기본 상태에 있습니다.

Focused 16

항목에 포커스가 있습니다.

Grayed 2

항목을 사용할 수 없습니다.

Hot 64

항목이 현재 마우스 포인터 아래에 있습니다.

Indeterminate 256

항목이 결정되지 않은 상태에 있습니다.

Marked 128

항목이 표시됩니다.

Selected 1

항목이 선택되어 있습니다.

ShowKeyboardCues 512

항목이 바로 가기 키를 나타냅니다.

예제

다음 예제에서는 사용자 지정 그리기를 제공 하는 방법에 설명 된 ListView 제어 합니다. ListView 배경이 그라데이션 예제에서 컨트롤입니다. 음수 값을 사용 하 여 하위 항목에 빨간 전경 및 검은색 배경 있습니다.

에 대 한 처리기를 ListView.DrawItem 이벤트 열 머리글 행 및 전체 항목에 대 한 배경을 그립니다. 에 대 한 처리기를 ListView.DrawSubItem 이벤트 텍스트 값 및 텍스트와 음수 값이 있는 하위 항목의 배경을 그립니다.

ContextMenu 구성 요소는 세부 정보 보기와 목록 간에 전환 하는 방법을 제공 합니다. 목록 뷰에서 ListView.DrawItem 이벤트가 발생 합니다. 이 경우 텍스트와 배경 둘 다에서 그려지는 ListView.DrawItem 이벤트 처리기입니다.

전체 예제를 참조 하세요.를 ListView.OwnerDraw 참조 항목입니다.

// 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

설명

이 열거형은에서 사용 합니다 DrawListViewItemEventArgs.StateDrawListViewSubItemEventArgs.ItemState 속성입니다. 자세한 내용은 참조는 ListView.DrawItemListView.DrawSubItem 이벤트입니다.

적용 대상

추가 정보