DrawListViewItemEventArgs.Bounds Property


Gets the size and location of the ListViewItem to draw.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public Rectangle Bounds { get; }

Property Value

Type: System.Drawing.Rectangle

A Rectangle that represents the bounds of the ListViewItem to draw.

The location specified by this property is relative to the upper left corner of the ListView control.

To retrieve the bounds for specific portions of a ListViewItem, use the ListViewItem.GetBounds method.

The following code example demonstrates how to use the Bounds property in an application that provides custom drawing for a ListView control. In the example, a handler for the ListView.DrawItem event draws the background for entire items. In all views except the details view, this handler also draws the foreground text. In the details view, the foreground text is drawn in the ListView.DrawSubItem event.

For the complete example, see the DrawListViewItemEventArgs overview reference topic.

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

.NET Framework
Available since 2.0
Return to top