ListViewItemStates 열거형
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
ListViewItem가능한 상태를 나타내는 상수 정의
이 열거형은 멤버 값의 비트 조합을 지원합니다.
public enum class ListViewItemStates
[System.Flags]
public enum ListViewItemStates
[<System.Flags>]
type ListViewItemStates =
Public Enum ListViewItemStates
- 상속
- 특성
필드
| Name | 값 | Description |
|---|---|---|
| Selected | 1 | 항목이 선택되어 있습니다. |
| Grayed | 2 | 항목을 사용할 수 없습니다. |
| Checked | 8 | 항목이 선택되어 있습니다. |
| Focused | 16 | 항목에 포커스가 있습니다. |
| Default | 32 | 항목이 기본 상태입니다. |
| Hot | 64 | 항목이 현재 마우스 포인터 아래에 있습니다. |
| Marked | 128 | 항목이 표시됩니다. |
| Indeterminate | 256 | 항목이 확정되지 않은 상태입니다. |
| 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.State 속성에서 DrawListViewSubItemEventArgs.ItemState 사용됩니다. 자세한 내용은 및 ListView.DrawItem 이벤트를 참조 ListView.DrawSubItem 하세요.