C#如何在ListView失去焦點的情況下仍然保持Item高亮
阿新 • • 發佈:2019-02-06
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;
}
}