ListView をスキャンして、特定の文字列に一致するサブアイテムを見つけるのに問題があります。これが私のコードです:
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
string date = datePicker.Value.ToShortDateString();
int count = Program.booker.listView.Items.Count;
for (int i = 0; i < count; i++)
{
ListViewItem lvi = Program.booker.listView.Items[i];
if (lvi.SubItems.Equals(date))
{
MessageBox.Show("Found!", "Alert");
Program.booker.listView.MultiSelect = true;
Program.booker.listView.Items[i].Selected = true;
}
else
{
MessageBox.Show("Nothing found for " + date, "Alert");
}
}
}
ListView は Booker フォームにあり、Filter クラスからアクセスしています。日付文字列に一致するアイテムを ListView 全体で検索したいと思います。ありがとう!