Share via


DrawListViewItemEventArgs.Bounds Özellik

Tanım

Çizecek öğesinin ListViewItem boyutunu ve konumunu alır.

public:
 property System::Drawing::Rectangle Bounds { System::Drawing::Rectangle get(); };
public System.Drawing.Rectangle Bounds { get; }
member this.Bounds : System.Drawing.Rectangle
Public ReadOnly Property Bounds As Rectangle

Özellik Değeri

Rectangle Çizecek öğesinin sınırlarını ListViewItem temsil eden bir.

Örnekler

Aşağıdaki kod örneği, bir denetim için ListView özel çizim sağlayan bir uygulamada özelliğinin nasıl kullanılacağını Bounds gösterir. Örnekte, olay işleyicisi ListView.DrawItem tüm öğelerin arka planını çizer. Ayrıntılar görünümü dışındaki tüm görünümlerde, bu işleyici ön plan metnini de çizer. Ayrıntılar görünümünde, olayda ListView.DrawSubItem ön plan metni çizilir.

Tam örnek için genel bakış başvuru konusuna DrawListViewItemEventArgs 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 özellik tarafından belirtilen konum, denetimin sol üst köşesine göredir ListView .

bir ListViewItemöğesinin belirli bölümlerinin sınırlarını almak için yöntemini kullanın ListViewItem.GetBounds .

Şunlara uygulanır

Ayrıca bkz.