D
Danny T
In .net 2.0 (beta 1), I've got a ListView that contains 1000 items. I've
set it so when I click the heading of a column, it groups by that column.
All works fine, but because the listview is redrawing after every
change, it's quite slow. If I uncomment the .Visible lines, it's *very*
fast, but obviously the control is invisible for a moment (causes a
flicker).
Is there any way to stop the control redrawing/painting/invalidating
while I perform these loops other than hiding the control?
private void listView1_ColumnClick(object sender, ColumnClickEventArgs e)
{
//listView1.Enabled = false;
foreach (ListViewItem l in listView1.Items)
{
bool newGroup = false;
newGroup = true;
foreach (ListViewGroup g in listView1.Groups)
{
if (g.Header == l.SubItems[e.Column].Text)
{
newGroup = false;
l.Group = g;
break;
}
}
if (newGroup)
{
ListViewGroup g = new
ListViewGroup(l.SubItems[e.Column].Text);
listView1.Groups.Add(g);
l.Group = g;
}
}
//listView1.Enabled = true;
}
set it so when I click the heading of a column, it groups by that column.
All works fine, but because the listview is redrawing after every
change, it's quite slow. If I uncomment the .Visible lines, it's *very*
fast, but obviously the control is invisible for a moment (causes a
flicker).
Is there any way to stop the control redrawing/painting/invalidating
while I perform these loops other than hiding the control?
private void listView1_ColumnClick(object sender, ColumnClickEventArgs e)
{
//listView1.Enabled = false;
foreach (ListViewItem l in listView1.Items)
{
bool newGroup = false;
newGroup = true;
foreach (ListViewGroup g in listView1.Groups)
{
if (g.Header == l.SubItems[e.Column].Text)
{
newGroup = false;
l.Group = g;
break;
}
}
if (newGroup)
{
ListViewGroup g = new
ListViewGroup(l.SubItems[e.Column].Text);
listView1.Groups.Add(g);
l.Group = g;
}
}
//listView1.Enabled = true;
}