Refresh icon of ListView

G

Guest

I've noticed that the graphics of a ListView image (either in SmallImageList or LargeImageList) are not updated after an image is set to a new image until the ListView is refreshed. As an example, if you do this

MyListView.SmallImageList.Images(0) = myNewBitma

Then the graphics of MyListView will not display the new image until you do something like this

MyListView.Refres

But, calling MyListView.Refresh can cause the client area to flicker and I have a situation where it is possible for a single image to be updated rapidly. Therefore, it would be nice if I could tell the ListView to only update the graphics of the image that changed. Is that type of thing possible

Thanks
Lance
 
A

Ayaz Ahmed

Hello,

use Image list

ListViewsearch.ListItems.Add , "Accounts", "Accounting", , 1
ListViewsearch.ListItems.Add , "Bills", "Billing", , 2
ListViewsearch.ListItems.Add , "Classes", "Classes", , 3
ListViewsearch.ListItems.Add , "Information System", "Information", , 4
ListViewsearch.ListItems.Add , "Payroll", "Payroll", , 5

i hope its will help you.

Thanks,


Warm Regards,

Ayaz Ahmed
Software Engineer & Web Developer
Creative Chaos (Pvt.) Ltd.
"Managing Your Digital Risk"
http://www.csquareonline.com
Karachi, Pakistan
Mobile +92 300 2280950
Office +92 21 455 2414
 
P

Peter Huang

Hi Lance,

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that when you change the the image in
the imagelist which is associated with the listview, the listview picture
will not update until you call the refresh.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

Because when we change the image in the imagelist, e.g. the first one, but
there may be more than one item in the listview associated with the
picture, to call the refresh will refresh all the item in the listview.

If you want to cause the update of certain item, I think you may try to
change the imageidex of the certain item you want to update, so that it
will be changed.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
ListView1.SmallImageList.Images(0) = New Bitmap("c:\green.bmp")
ListView1.Items(0).ImageIndex = 1
ListView1.Items(0).ImageIndex = 0
End Sub

Please apply my suggestion above and let me know if it helps resolve your
problem.


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

That is exactly the type of thing that I want to do, but unfortunately your solution results in much worse flicker for the item that is being updated (when compared to calling Refresh). In other words, calling Refresh causes a subtle flicker for all of the items in the ListView, whereas changing the ImageIndex property causes very noticable flicker for the item that is being modified. I also tried a test where I invalidated a pre-determined region that corresponds to the image that is being modified, but that resulted in same amount of flicker as changing the ImageIndex property. Of course an optimal solution would be to refresh only the region that corresponds to the image that is being modifed. Any other ideas

Thanks again
Lanc
 
P

Peter Huang

Hi Lance,

Since in my test program, I use a small picture, I did not notice the
flicker.
But I think you may try to call the ListView.BeginUpdate and
ListView.EndUpdate Methods.
e.g.
ListView1.BeginUpdate()
ListView1.SmallImageList.Images(0) = New Bitmap("c:\green.bmp")
ListView1.Items(0).ImageIndex = 1
ListView1.Items(0).ImageIndex = 0
ListView1.EndUpdate ()

to see if this help you.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top