/// <summary> /// Return bounds of the given subitem /// </summary> /// <remarks>This correctly calculates the bounds even for column 0.</remarks> public virtual Rectangle GetSubItemBounds(int subItemIndex) { if (subItemIndex == 0) { Rectangle r = this.Bounds; Point sides = NativeMethods.GetScrolledColumnSides(this.ListView, subItemIndex); r.X = sides.X + 1; r.Width = sides.Y - sides.X; return(r); } OLVListSubItem subItem = this.GetSubItem(subItemIndex); return(subItem == null ? new Rectangle() : subItem.Bounds); }
/// <summary> /// Draw a slight colouring over our tinted column /// </summary> /// <remarks> /// This overlay only works when: /// - the list is in Details view /// - there is at least one row /// - there is a selected column (or a specified tint column) /// </remarks> /// <param name="olv"></param> /// <param name="g"></param> /// <param name="r"></param> public override void Draw(AdvancedListView olv, Graphics g, Rectangle r) { if (olv.View != System.Windows.Forms.View.Details) { return; } if (olv.GetItemCount() == 0) { return; } OLVColumn column = this.ColumnToTint ?? olv.SelectedColumn; if (column == null) { return; } Point sides = NativeMethods.GetScrolledColumnSides(olv, column.Index); if (sides.X == -1) { return; } Rectangle columnBounds = new Rectangle(sides.X, r.Top, sides.Y - sides.X, r.Bottom); // Find the bottom of the last item. The tinting should extend only to there. OLVListItem lastItem = olv.GetLastItemInDisplayOrder(); if (lastItem != null) { Rectangle lastItemBounds = lastItem.Bounds; if (!lastItemBounds.IsEmpty && lastItemBounds.Bottom < columnBounds.Bottom) { columnBounds.Height = lastItemBounds.Bottom - columnBounds.Top; } } g.FillRectangle(this.tintBrush, columnBounds); }