1. 程式人生 > >C#如何在ListView失去焦點的情況下仍然保持Item高亮

C#如何在ListView失去焦點的情況下仍然保持Item高亮


private void listView_Validated(object sender, EventArgs e)
{
if (listView.FocusedItem != null)
{
listView.FocusedItem.BackColor = SystemColors.Highlight;
listView.FocusedItem.ForeColor = Color.White;
}
}

private void listView_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
{
e.Item.ForeColor = Color.Black;
e.Item.BackColor = SystemColors.Window;

if (listView.FocusedItem != null)
{
listView.FocusedItem.Selected = true;
}
}