Change background selection color of ListView?
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);
}
Well for WinForms you have to set the OwnerDraw
property to true and then use the DrawItem
and DrawSubItem
events to draw the item manually.
See here for an example.