Solved

Keeping list view item selected

Posted on 2003-11-27
2
963 Views
Last Modified: 2008-02-01
Is there a way to keep a list view item selected graphically (with the blue highlight) even when the listview does not have the focus?
0
Comment
Question by:jjacksn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Expert Comment

by:DaniPro
ID: 9835734
You can use the SelectedIndexChanged Event for change the listviewitem color (if you use the multiselect option you must change the foreach loop):

private void listView1_SelectedIndexChanged(object sender, System.EventArgs e)
{
      foreach (ListViewItem lvi in listView1.Items)//listView1.SelectedItems)
      {
            lvi.BackColor = System.Drawing.SystemColors.Info;
            lvi.ForeColor = System.Drawing.SystemColors.InfoText;
      }
      listView1.FocusedItem.BackColor = System.Drawing.SystemColors.Highlight;
      listView1.FocusedItem.ForeColor = System.Drawing.SystemColors.HighlightText;                  
}
0
 
LVL 1

Accepted Solution

by:
AJMartin earned 250 total points
ID: 9835787
Set the property:
 HideSelection
to false and your problem will be solved.

Quoted from .NET Framework SDK Documentation:
Property Value [is] true if the selected item does not appear highlighted when the control loses focus; false if the selected item still appears highlighted when the control loses focus. The default is true.

Remarks
When this property is set to false, selected items in the ListView control remain highlighted in a different color than the current selection color specified by the operating system when the ListView control loses focus. You can use this property to keep items that are selected by the user visible when the user clicks a different control on the form or moves to a different window.

I hope that helps!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question