Решено через попу... Кому интересно:
| Код | public static void DrawItem(object sender, DrawListViewItemEventArgs e) { int x = e.Item.Bounds.X; int w = e.Item.ListView.Columns[0].Width; for (int i = 1; i < e.Item.ListView.Columns.Count; ++i) { if (e.Item.ListView.Columns[i].DisplayIndex < e.Item.ListView.Columns[0].DisplayIndex) x += e.Item.ListView.Columns[i].Width; } string text = e.Item.Text; int cx, cy; e.Graphics.MeasureString(text, e.Item.Font, new SizeF(w, 10000), StringFormat.GenericDefault, out cx, out cy); bool tt = false; while (cy>1 && text.Length>0) { tt = true; text = text.Remove(cx - 1); e.Graphics.MeasureString(text+"...", e.Item.Font, new SizeF(w, 10000), StringFormat.GenericDefault, out cx, out cy); cx = text.Length; } Rectangle rect = new Rectangle(x, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height); if (e.Item.Selected) e.Graphics.FillRectangle(Brushes.Purple, e.Bounds); else e.Graphics.FillRectangle(new SolidBrush(e.Item.BackColor), e.Bounds); e.Graphics.DrawString(text + (tt ? "..." : ""), e.Item.Font, new SolidBrush(e.Item.ForeColor), rect); }
public static void DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { if (e.ItemIndex < 0) return; if (e.ColumnIndex == 0) return; e.SubItem.BackColor = e.Item.BackColor; if (e.Item.Selected) e.Graphics.FillRectangle(Brushes.Purple, e.Bounds); else e.Graphics.FillRectangle(new SolidBrush(e.SubItem.BackColor), e.Bounds); e.DrawText(); }
public static void DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e) { e.DrawBackground(); e.DrawText(); }
|
|