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 } 

 

posted @ 2023-12-08 10:36  soliang  阅读(272)  评论(0编辑  收藏  举报