Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi!

I have a listview where I show the values for about 50 different points of measurement. They all update (individually) about twice a second and I want to show the values as soon as possible.

At the moment I'm looping through the listviewitems in order to find the right one (based on the items text) but the control is flickering (and it seem like it's eating memory but I might be wrong there).

 

Is there a better way to update the list?

(Sensor is the sensor class which holds the properties of the sensors, such as Value, Name, Location , ...)

 

This is (a part of) my event handler in the form.

Synclock lvwValues
   Dim itm as listviewitem

   For each itm in lvwValues
       if Sensor.Name=itm.text then
           itm.Subitem(1).Text=Sensor.Value
           exit for
       End if
   next

end Synclock

 

TIA

Kejpa

Posted (edited)

Hmmm...had a similiar problem once that I did the same thing for, but now that I learned more and if I had to do it all over again I would try to have a hash-table that is built at the same time the list view is being built. What this does for you is allow you to easily find the item (your text would be your key...it sounds like, like me, they were all unique; that's the only way this would work), and then the value would be the ListItem.Item and you would cast as so and work from there.

 

Now whether this would work or not, I don't know; it should since both your key and your item are object types; but with I don't know how that would work with the ListItem.Item - not good enough with my ref vs. type stuff to know if that would cause a problem, don't think it should... but let me know how it works out for you.

 

Your flickering maybe because of something else too... I didn't really have a flicker problem, and my listview held over a thousand items, but then I wasn't updating it every two seconds either... I'm curious what the other more experianced folks will have to say.

Edited by bri189a
Posted

Yeah, I made a hashtable to hold the Text and listviewitem and it's working.

I'm no longer sure that it was looping to listview that caused it all to jam, it might be some of the Event Handlers.

Still flickering though, but not as much as before.

 

Still.... More input is appreciated ;)

 

Thanx

Kejpa

Posted
When are you doing the actual updates... in otherwords theres the whole Begin Update and End Update approach... I was hitting the BeginUpdate() before going into the loop, and the EndUpdate() after exiting the loop; I assumed you were using it, but after chewing on this some, maybe you aren't...this could be why you get flickering on so few and I never had any flickering at all; let me know.
  • *Experts*
Posted
I agree with kejpa about the Begin and End Updates...they also caused more flickering and flashing than not having them at all. Kejpa, have you tried loading the listview from an array? This helped solve my flickering problem to almost null...almost.

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

Posted
You don't have your BeginUpdate, EndUpdate in the loop do you? I have no issues with it at all, if I pull them out then I have all sorts of flickering too.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...