Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Keeping list view item selected

Posted on 2003-11-27
2
Medium Priority
?
967 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 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

660 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