protected virtual void TriggerFormatRowEvent(int rowIndex, int displayIndex, OLVListItem olvi)
{
FormatRowEventArgs args = new FormatRowEventArgs();
args.ListView = this;
args.RowIndex = rowIndex;
args.DisplayIndex = displayIndex;
args.Item = olvi;
args.UseCellFormatEvents = this.UseCellFormatEvents;
this.OnFormatRow(args);
if (args.UseCellFormatEvents && this.View == View.Details) {
// If a cell isn't given its own color, it should use the color of the item.
// However, there is a bug in the .NET framework where the cell are given
// the color of the ListView instead. So we have to explicitly give each
// cell the back color that it should have.
olvi.UseItemStyleForSubItems = false;
Color backColor = olvi.BackColor;
for (int i = 0; i < this.Columns.Count; i++) {
olvi.SubItems[i].BackColor = backColor;
}
// Fire one event per cell
FormatCellEventArgs args2 = new FormatCellEventArgs();
args2.ListView = this;
args2.RowIndex = rowIndex;
args2.DisplayIndex = displayIndex;
args2.Item = olvi;
for (int i = 0; i < this.Columns.Count; i++) {
args2.ColumnIndex = i;
args2.Column = this.GetColumn(i);
args2.SubItem = olvi.GetSubItem(i);
this.OnFormatCell(args2);
}
}
}