Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a listview with 200+ items in it and I have a code that changes the font color of certain items.. is there a way I can display in a label the number of items that are a certain font color?

 

Like... If listview.forecolor.red Then... more code

  • Leaders
Posted

Why not declare a variable in which to keep count for each color (provided that there is a reasonably small number of colors), and whenever you change the font color increment and decrement the appropriate variables.

 

Otherwise, you can certainly use the code you provided, but since you have a lot of items, and you must recount the totals on the fly it might cause a small lag.

 

Function MatchCount(ListView As ListView, Color As Color) As Integer
   Dim Total As Integer
   For Each Item As ListViewItem In ListView
       If Item.ForeColor = Color Then _
           Total += 1
   Next
   Return Total
End Function

[sIGPIC]e[/sIGPIC]

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...