ListView Selected Background Changes When Loses Focus


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: ListView Selected Background Changes When Loses Focus

  1. #1
    Join Date
    Aug 2005
    Posts
    2

    ListView Selected Background Changes When Loses Focus

    I recently converted several ListBox selection lists to ListView selection lists. Selected items in the ListView have a nice dark blue background when it has focus, but change to a pale tan/gray upon losing focus. This is very confusing to the users as it is difficult to discern which records are selected in the Listview. Is there any way to disable the color switch or a way to set it to the "in-focus" color?

  2. #2
    Join Date
    Feb 2004
    Location
    Sydney, Australia
    Posts
    498
    Don't believe you can still use the 'highlighted' focus colour when the listview no longer has the focus - that is a Windows function.

    However, to make it clearer to users what has been 'selected', each time an item is selected, you can change the foreground colour e.g.

    (with approp Dim's for iIndex and iColumns (and setting iColumns to the approp value)

    Code:
    lvMyListView.SelectedItem.ForeColor = vbBlue ( or vbRed .... etc)
    For iIndex = 1 To iColumns
        lvMyListView.SelectedItem.ListSubItems(iIndex).ForeColor = vbBlue
    Next
    [N.B. In the For ... Next loop, I have no idea why 'Forecolor' is appearing as 'For ecolor'!!! - I have tried everything I can think of to correct, but .... anyone at DevX have an idea?]

    We use this, for example, when users are clicking on 'presented' items when doing a Bank Reconciliation.

    P.S. You can also use '.SelectedItem.Checked = True', if you tick 'Checkboxes' in the ListView Properties.

    Hope this helps

    Greg

Similar Threads

  1. Get ListView selected item
    By JohnP in forum .NET
    Replies: 1
    Last Post: 08-01-2005, 11:21 PM
  2. Listview Background
    By moe188 in forum VB Classic
    Replies: 1
    Last Post: 04-06-2005, 01:45 PM
  3. Script for scrolling
    By Mark in forum Web
    Replies: 3
    Last Post: 08-30-2001, 11:45 AM
  4. WebBrowser Loses Focus (Ctrl-F3 won't work)
    By Jason Savard in forum VB Classic
    Replies: 0
    Last Post: 08-03-2000, 08:06 PM
  5. WebBrowser Loses Focus (Ctrl-F3 won't work)
    By Jason Savard in forum VB Classic
    Replies: 0
    Last Post: 08-03-2000, 08:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center