Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Well actually you can have multiple items in a listview each one with different colors, first you need to declare a variable that will contain the Color class

 

Dim Clr as System.Drawing.Color

 

After that start filling your Listview with your items and subitems, but after setting the first column you need to set the color

 

ListView1.Items.Add("Item One")
ListView1.Items.Item(i).ForeColor = Clr.Red
ListView1.Items(i).SubItems.Add("SubItem One")

 

All subitems will take the color, the example should look something like this

 

Private Sub Button1_Click (ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim i as Integer
Dim Clr as System.Drawing.Color

For i=0 to 100
    ListView1.Items.Add("Item " & i)
    ListView1.Items.Item(i).ForeColor = Clr.Red
    ListView1.Items(i).SubItems.Add("SubItem " & i)
Next
End Sub

 

You can change the color for each item in the listview, try it out, and let me know if you have any problems

 

Regards

Fat kids are harder to kidnap
Posted

SOLUTION:

I change the color of individual cells in a List View control.

I highlight cells in pink to show errors.

 

lvwStats.Items(iIndex).SubItems(3).BackColor = Color.LightPink 

 

Normally my ListView is all white, with scattered cells highlighted in pink.

Posted

You have to set up for column independence at item-add time.

Example:

 
itemNew.SubItems.Add("item1") 
itemNew.SubItems.Add("item2")       
itemNew.UseItemStyleForSubItems = False ' Cell independence...
lvwTest.Items.AddRange(New ListViewItem() {itemNew})  

Hey, I finally stumped the moderators on one!

Do I get a badge or something?

 

.

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