Is there a workaround for Linux mono's refusal to acknowledge that I have resized the columns of my
- by fantius
When I resize a column, it does not redraw the data with the updated alignment. I've tried Invalidating, Refreshing, and a few other things. Nothing has worked. Does anyone know a workaround? I have not tried this in mono for Windows.
To see what I mean, drop this control on a form, and run it in mono for Linux:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
class MyListView : ListView
{
private readonly List<ListViewItem> items_ = new List<ListViewItem>();
public MyListView()
{
VirtualMode = true;
Columns.Add("Col 1");
Columns.Add("Col 2");
Columns.Add("Col 3");
Add(new ListViewItem(new[] { "a", "b", "c" }));
Add(new ListViewItem(new[] { "a", "b", "c" }));
Add(new ListViewItem(new[] { "a", "b", "c" }));
Add(new ListViewItem(new[] { "a", "b", "c" }));
Add(new ListViewItem(new[] { "a", "b", "c" }));
}
protected override void OnRetrieveVirtualItem(RetrieveVirtualItemEventArgs e)
{
e.Item = items_[e.ItemIndex];
base.OnRetrieveVirtualItem(e);
}
public void Add(ListViewItem item)
{
items_.Add(item);
VirtualListSize = items_.Count;
}
protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e)
{
e.DrawText();
base.OnDrawColumnHeader(e);
}
protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
{
var text = ((ListViewItem.ListViewSubItem)e.SubItem).Text;
using (var brush = new SolidBrush(e.SubItem.ForeColor))
{
e.Graphics.DrawString(text, Font, brush, e.Bounds);
}
base.OnDrawSubItem(e);
}
protected override void OnColumnWidthChanged(ColumnWidthChangedEventArgs e)
{
base.OnColumnWidthChanged(e);
Invalidate(true); // Nope, that didn't work
Refresh(); // Nope, that didn't work
}
}