ListViewItemStates Sabit listesi

Tanım

ListViewItemolası durumlarını temsil eden sabitleri tanımlar.

Bu sabit listesi, üyeleri için bit düzeyinde karşılaştırmayı destekler.

public enum class ListViewItemStates
[System.Flags]
public enum ListViewItemStates
[<System.Flags>]
type ListViewItemStates = 
Public Enum ListViewItemStates
Devralma
ListViewItemStates
Öznitelikler

Alanlar

Name Değer Description
Selected 1

Öğe seçilir.

Grayed 2

Öğe devre dışı bırakıldı.

Checked 8

Öğe denetlendi.

Focused 16

Öğenin odağı vardır.

Default 32

Öğe varsayılan durumundadır.

Hot 64

Öğe şu anda fare işaretçisinin altında.

Marked 128

Öğe işaretlenir.

Indeterminate 256

Öğe belirsiz bir durumda.

ShowKeyboardCues 512

Öğe bir klavye kısayolu göstermelidir.

Örnekler

Aşağıdaki örnekte, bir denetim için özel çizim sağlama gösterilmektedir ListView . Örnekteki ListView denetimin gradyan arka planı vardır. Negatif değerlere sahip alt öğeleri kırmızı ön plana ve siyah arka plana sahiptir.

Olay işleyicisi ListView.DrawItem , öğelerin tamamı ve sütun üst bilgileri satırı için arka planı çizer. Olay işleyicisi ListView.DrawSubItem , metin değerlerini ve negatif değerlere sahip alt öğeleri için hem metni hem de arka planı çizer.

ContextMenu Bileşen, ayrıntılar görünümüyle liste arasında geçiş yapmak için bir yol sağlar. Liste görünümünde yalnızca ListView.DrawItem olay tetiklenir. Bu durumda, hem metin hem de arka plan olay işleyicisinde ListView.DrawItem çizilir.

Tam örnek için başvuru konusuna ListView.OwnerDraw bakın.

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

Açıklamalar

Bu numaralandırma ve DrawListViewItemEventArgs.State özellikleri tarafından DrawListViewSubItemEventArgs.ItemState kullanılır. Daha fazla bilgi için ve ListView.DrawItem olaylarına ListView.DrawSubItem bakın.

Şunlara uygulanır

Ayrıca bkz.