Solved

Keeping list view item selected

Posted on 2003-11-27
2
939 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
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need help on C# Linq query on object 6 62
Media.Imaging 1 18
Cant save 3D 4 19
Getting error in connectionstring with Excel. 30 31
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

776 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