Results 1 to 3 of 3

Thread: Highlighting in a ListBox (RESOLVED)

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    Highlighting in a ListBox (RESOLVED)

    Hi,

    Please does anyone know how to highlight in colour one particular entry in a ListBox without affecting the others entries? I have got as far as realising that I have to make the ListBox Owner-Draw.

    Then I have to put the entries into separate rectangles which have the appropriate back and fore colours, but I can't figure that out.
    Last edited by taxes; May 27th, 2004 at 04:45 PM.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367
    Do you have to use a listbox? If you use a listview, this is very easy:

    VB Code:
    1. Dim li As ListViewItem
    2.         Dim ch As ColumnHeader
    3.  
    4.         'Set the view, so it looks like a listbox
    5.         ListView1.View = View.Details
    6.  
    7.         'Create a new column, this can be done from the IDE using the column collection
    8.         ch = New ColumnHeader
    9.         ch.Text = "Column1"
    10.         ListView1.Columns.Add(ch)
    11.  
    12.         'Add the items to the listview
    13.         li = ListView1.Items.Add("A")
    14.         li.ForeColor = Color.Red
    15.         li = ListView1.Items.Add("B")
    16.         li.ForeColor = Color.Blue
    17.         li = ListView1.Items.Add("C")
    18.         li.BackColor = Color.Black
    19.         li.ForeColor = Color.White

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Many thanks for prompt reply.

    Good idea.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

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