当我拖过 Listview 项目时如何获取选定的项目和子项目。我试过这个,但没有得到准确的解决方案。我只在第一次鼠标悬停 Selected 项目时得到了解决方案。当我一直悬停不同的项目时,它不会显示最新的悬停项目
private void lvThumbnail_MouseHover(object sender, EventArgs e)
{
try
{
if (lvThumbnail.SelectedItems.Count > 0)
{
txtCity.Text = lvThumbnail.SelectedItems[0].SubItems[1].Text;
txtCurrency.Text = lvThumbnail.SelectedItems[0].SubItems[2].Text;
txtPopulation.Text = lvThumbnail.SelectedItems[0].SubItems[3].Text;
txtLanguage.Text = lvThumbnail.SelectedItems[0].SubItems[4].Text;
lvThumbnail.Refresh();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}