C# ListView失去焦点仍然保持选中的Item高亮
1 private void listView_Validated( object sender, EventArgs e) 2 { 3 if (listView.FocusedItem != null ) 4 { 5 listView.FocusedItem.BackColor = SystemColors.Highlight; 6 listView.FocusedItem.ForeColor = Color.White; 7 } 8 } 9 10 private void listView_ItemSelectionChanged( object sender, ListViewItemSelectionChangedEventArgs e) 11 { 12 e.Item.ForeColor = Color.Black; 13 e.Item.BackColor = SystemColors.Window; 14 15 if (listView.FocusedItem != null ) 16 { 17 listView.FocusedItem.Selected = true ; 18 } 19 }