Hello. How can I change the selection color on a ListView? By default, when the user selects an item it shows a blue background. I want to change this to dark gray, or something... Thanks for the help!
Here's an example to do this in WPF
As far as WinForms Listviews go, I don't think they're flexable enough to do what you want, but here is a custom made listview that adds a lot of new features, including changing the colors of rows. He has several examples on that same page showing how to use his control.
If you wanted your ListView
to have the style of the Windows Explorer ListView
(including the nice appearance with rounded edges in Win7/Vista), you could use a little P/Invoke to accomplish that:
[DllImport("uxtheme.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
internal static extern int SetWindowTheme(IntPtr hWnd, string appName, string partList);
// You can subclass ListView and override this method
protected override void OnHandleCreated(EventArgs e)
{
base.OnHandleCreated(e);
SetWindowTheme(this.Handle, "explorer", null);
}
ObjectListView -- a wrapper around a WinForm ListView -- has properties to let you control the background and foreground color of the selected rows. It uses the technique that Obalix suggested, but it has already done the hard work for you.
So, with a little effort, you can produce something like this:
The "Feel Good Inc" row show a custom foreground and background for selection.