Results 1 to 10 of 10

Thread: [2005] Colour in the ListView

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2008
    Posts
    15

    [2005] Colour in the ListView

    Hi guys,

    Do you know how to put a color font the data in the ListView please.
    So, I want the 1st row with red font, the 2nd row with blue color, 3rd row red again and so on.

    Does anyone know how to do this please.

    Thank you.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Colour in the ListView

    Set the ForeColor property of each item. You'll need to set the UseItemStyleForSubItems property to True or else only the first column will be coloured.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2008
    Posts
    15

    Re: [2005] Colour in the ListView

    Could you give me an example please.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Colour in the ListView

    How about you give it a try and we'll help fix it if it doesn't work. The best way to learn is to do.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    New Member
    Join Date
    Jun 2008
    Posts
    15

    Re: [2005] Colour in the ListView

    Please have a look at tha attachement.
    I want the listView look similar like that, but only 1 row is red, 2nd is blue, 3rd is red again and so on.

    Thank you.
    Attached Images Attached Images  

  6. #6
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Re: [2005] Colour in the ListView

    Can you post your code what you did? how you populate the listview as above, so that we can help you.,
    Visual Studio.net 2010
    If this post is useful, rate it


  7. #7

    Thread Starter
    New Member
    Join Date
    Jun 2008
    Posts
    15

    Re: [2005] Colour in the ListView

    'Dim Itema = New ListViewItem
    'For Each Itema In ListView1.Items
    ' If (Itema.Index Mod 2) = 0 Then
    ' 'Itema.BackColor = Color.Red
    ' Itema.ForeColor = Color.Red
    ' Else
    ' 'Itema.BackColor = Color.Yellow
    ' Itema.ForeColor = Color.Yellow
    ' End If
    'Next

  8. #8

    Thread Starter
    New Member
    Join Date
    Jun 2008
    Posts
    15

    Re: [2005] Colour in the ListView

    that code take ages. longtime to load if I combine uploading the date into the ListView.

    Is there a way to load faster?

  9. #9

    Thread Starter
    New Member
    Join Date
    Jun 2008
    Posts
    15

    Re: [2005] Colour in the ListView

    jmchilhinney, do you know how to do this faster? or anyone please?

    thank you

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Colour in the ListView

    I think we've already discussed this in another thread but you should call BeginUpdate first and EndUpdate last. Otherwise the ListView will be redrawn after each item is changed or added. The continual redrawing makes things very slow.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width