public override void DrawListViewHeader (Graphics dc, Rectangle clip, ListView control) { bool details = (control.View == View.Details); // border is drawn directly in the Paint method if (details && control.HeaderStyle != ColumnHeaderStyle.None) { dc.FillRectangle (SystemBrushes.Control, 0, 0, control.TotalWidth, control.Font.Height + 5); if (control.Columns.Count > 0) { foreach (ColumnHeader col in control.Columns) { Rectangle rect = col.Rect; rect.X -= control.h_marker; #if NET_2_0 bool owner_draw = false; if (control.OwnerDraw) owner_draw = DrawListViewColumnHeaderOwnerDraw (dc, control, col, rect); if (owner_draw) continue; #endif ListViewDrawColumnHeaderBackground (control, col, dc, rect, clip); rect.X += 5; rect.Width -= 10; if (rect.Width <= 0) continue; #if NET_2_0 int image_index; if (control.SmallImageList == null) image_index = -1; else image_index = col.ImageKey == String.Empty ? col.ImageIndex : control.SmallImageList.Images.IndexOfKey (col.ImageKey); if (image_index > -1 && image_index < control.SmallImageList.Images.Count) { int image_width = control.SmallImageList.ImageSize.Width + 5; int text_width = (int)dc.MeasureString (col.Text, control.Font).Width; int x_origin = rect.X; int y_origin = rect.Y + ((rect.Height - control.SmallImageList.ImageSize.Height) / 2); switch (col.TextAlign) { case HorizontalAlignment.Left: break; case HorizontalAlignment.Right: x_origin = rect.Right - (text_width + image_width); break; case HorizontalAlignment.Center: x_origin = (rect.Width - (text_width + image_width)) / 2 + rect.X; break; } if (x_origin < rect.X) x_origin = rect.X; control.SmallImageList.Draw (dc, new Point (x_origin, y_origin), image_index); rect.X += image_width; rect.Width -= image_width; } #endif dc.DrawString (col.Text, control.Font, SystemBrushes.ControlText, rect, col.Format); } int right = control.GetReorderedColumn (control.Columns.Count - 1).Rect.Right - control.h_marker; if (right < control.Right) { Rectangle rect = control.Columns [0].Rect; rect.X = right; rect.Width = control.Right - right; ListViewDrawUnusedHeaderBackground (control, dc, rect, clip); } } } }