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

Alternating Rows

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]

Leave a Reply