# Owl's Blog on .NET development

Component Owl codes Better ListView control all night so you don't have to.

## Alternating Rows in Better ListView

Blog Post by Libor Tinka published on Tuesday, 22 April 2014 in Better ListView, Tutorials

Alternating Rows

Lists with alternating row colors are more readable. It is very simple to implement alternating rows in Better ListView.

Simply add DrawItemBackground event handler and fill background on odd/even items:

[csharp gutter=”false” toolbar=”false”]
private void ListViewOnDrawItemBackground(object sender, BetterListViewDrawItemBackgroundEventArgs eventArgs)
{
if ((eventArgs.Item.Index & 1) == 1)
{
eventArgs.Graphics.FillRectangle(Brushes.AliceBlue, eventArgs.ItemBounds.BoundsOuter);
}
}
[/csharp]

Tags: alternating, better listview, colored, colors, even, odd, rows

### Leave a Reply

Click here to cancel reply.

Name (required)

Mail (will not be published) (required)

Website