2 Replies - 4752 Views - Last Post: 13 July 2011 - 05:51 AM Rate Topic: -----

#1 timmack  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 31-January 11

How set different colors on items and subitems of the listview control

Posted 13 July 2011 - 05:28 AM

I want to set a color on items and subitems being displayed within the listview control in a detailed view.
Using the forecolor property setting would change the color of all the contents in the listview control. All I want is to display different colors on each column of the listview control. If I have four colums on the listview, it should display the contents on each column in a different color. I tried to do it on my own but it was unsuccessful. I'm looking for the exact code to set the color successfully. Currently, the code below is what I have to display the data on the listview. What line of code should I add on the code below to set different colors on items and subitems of the listview?

 With ChildForm12.ListView1.Items

                    ChildForm12.Show()
                    lview = ChildForm12.ListView1.Items.Add(moviestat.Bar_Code)      'Just remain in black
                    lview.SubItems.Add(moviestat.Movies_Rented)                      'I want this in blue
                    lview.SubItems.Add(moviestat.No__of_Copies_Rented)               'I want this in red
                    lview.SubItems.Add(moviestat.Borrower_s_Name)                    'I want this in yellow

             End With


Is This A Good Question/Topic? 0
  • +

Replies To: How set different colors on items and subitems of the listview control

#2 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: How set different colors on items and subitems of the listview control

Posted 13 July 2011 - 05:47 AM

You will need to set the UseItemStyleForSubItems to False but all you should have to do is:
With ChildForm12.ListView1.Items
   ChildForm12.Show()
   lview = ChildForm12.ListView1.Items.Add(moviestat.Bar_Code)
   lview.SubItems.Add(moviestat.Movies_Rented).ForeColor = Color.Blue
   lview.SubItems.Add(moviestat.No__of_Copies_Rented).ForeColor = Color.Red
   lview.SubItems.Add(moviestat.Borrower_s_Name).ForeColor = Color.Yellow
   'now add this
   lview.UseItemStyleForSubItems = False
End With


This post has been edited by CharlieMay: 13 July 2011 - 05:49 AM

Was This Post Helpful? 1
  • +
  • -

#3 deery5000  Icon User is offline

  • D.I.C Addict

Reputation: 78
  • View blog
  • Posts: 973
  • Joined: 09-May 09

Re: How set different colors on items and subitems of the listview control

Posted 13 July 2011 - 05:51 AM

hi mate, i know this is not related to your topic. I too am building a dvd management application. Can you post an image of you progress?

Couldnt find an area where i can post my images and have people give feedback.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1