|
-
Apr 26th, 2004, 12:30 PM
#1
Thread Starter
Lively Member
How to stop a listview from being painted.
In my application I have a method that iterates over rows in a table to add them to a listview. When the listview is visible, the first few entries that go down till the edge of the application's window are really slow. As soon as it starts processing the entries that are out of view, it's fast.
In my loop, which looks like this:
VB Code:
For Each row In rows
Dim lvi As GlacialComponents.Controls.GLItem
lvi = glist.Items.Add(CType(row(1), String))
lvi.SubItems(1).Text = (CType(row(2), String))
lvi.SubItems(1).ForeColor = Color.Maroon
lvi.SubItems(2).Text = (CType(row(3), String))
lvi.SubItems(2).ForeColor = Color.DarkBlue
lvi.SubItems(3).Text = (CType(row(5), String))
lvi.SubItems(4).Text = (CType(row(6), String))
lvi.SubItems(4).ForeColor = Color.Green
lvi.SubItems(4).Font = verdanab
lvi.SubItems(5).Text = (CType(row(7), String))
lvi.SubItems(5).ForeColor = Color.DarkBlue
lvi.SubItems(5).Font = verdanab
lvi.SubItems(6).Text = (CType(row(4), String))
lvi.SubItems(7).Text = (CType(row(12), String))
progress.Value += 1
Next row
How can I stop the listview from painting on each row that way it processes quick? Then I can do glist.update() or is it glist.refresh() after the line with next row, is that right? Or am I missing something?
I should mention that turning off visibility also does the trick, but I want the listview to show an empty "dummy list" for aesthetics purposes.
This is essentially one of the last elements of my software before I go through and do some serious testing.
-
Apr 26th, 2004, 12:46 PM
#2
Frenzied Member
.BeginUpdate();
your code....
.EndUpdate();
these 2 methods were put in place because in vb6 the only way to prevent repaint was to make it invisible,
with .NET its easier, just use those 2 methods.
-
Apr 26th, 2004, 12:54 PM
#3
Thread Starter
Lively Member
Ok that definitely works but the screen flickers black. Is there any easy way to fix that? I guess I just wanna "freeze" the way the control looks before I start updating and then quickly repaint it afterwards.
Last edited by Kt3; Apr 26th, 2004 at 12:58 PM.
-
Apr 26th, 2004, 01:30 PM
#4
Frenzied Member
call the update method after your next statement. that lets the listview fill up and then it will be shown. Rather that be shown after every row which will cause it to flicker.
-
Apr 26th, 2004, 01:38 PM
#5
Thread Starter
Lively Member
That's what I assumed. I wouldn't want to update every time it loops, but either way, the screen still shows black for a few moments while it processes. No flickering, but still not pretty.
I'm gonna leave it like that for now, but how about using the addrange method of the listview.items property? I tried creating a new itemcollection like this:
VB Code:
Dim collect As New GlacialComponents.Controls.GLItemCollection(glist)
And during the loop, here's what happens:
VB Code:
Dim lvi As GlacialComponents.Controls.GLItem
lvi = collect.Add(CType(row(1), String))
' ...
'<rest of code ommitted>
but then I can't figure out how to add the Itemcollection to the listview after the next statement. The addrange method that belongs to the items property is supposed to do that but it accepts an "item array" and not an item collection, well what the hell is the difference?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|