BrightIdeasSoftware.ObjectListView.ApplyCellStyle C# (CSharp) Method

ApplyCellStyle() protected method

Apply a style to a cell
protected ApplyCellStyle ( BrightIdeasSoftware.OLVListItem olvi, int columnIndex, IItemStyle style ) : void
olvi BrightIdeasSoftware.OLVListItem
columnIndex int
style IItemStyle
return void
        protected virtual void ApplyCellStyle(OLVListItem olvi, int columnIndex, IItemStyle style)
        {
            if (style == null)
                return;

            // Don't apply formatting to subitems when not in Details view
            if (this.View != View.Details && columnIndex > 0)
                return;

            olvi.UseItemStyleForSubItems = false;

            ListViewItem.ListViewSubItem subItem = olvi.SubItems[columnIndex];
            if (style.Font != null)
                subItem.Font = style.Font;

            if (style.FontStyle != FontStyle.Regular)
                subItem.Font = new Font(subItem.Font ?? olvi.Font ?? this.Font, style.FontStyle);

            if (!style.ForeColor.IsEmpty)
                subItem.ForeColor = style.ForeColor;

            if (!style.BackColor.IsEmpty)
                subItem.BackColor = style.BackColor;
        }
ObjectListView