There is now a ListView (LV1), with 2 columns.
ListViewItem LVI = new ListViewItem ();
Lvi. Text = "Language";
Lvi. SubItems.Add ("99");
Lvi. Items.Add (LVI);
LVI = new ListViewItem ();
Lvi. Text = "Mathematics";
Lvi. SubItems.Add ("100");
Lvi. Items.Add (LVI);
A classmate looks like this: listviewitem[] Lvis = LVI. Items.Find ("math", true);
Or this: listviewitem[] Lvis = LVI. items["mathematics"];
This will not be the result. Because the first parameter in Find is key, which is the name of ListViewItem, because neither of the ListView has the name set, it is not possible to get the desired result. Lvi. items["mathematics");
If you modify the code as follows:
LVI = new ListViewItem ();
Lvi. Text = "Mathematics";
Lvi. Name = "Mathematics";
Lvi. SubItems.Add ("100");
Lvi. Items.Add (LVI);
You can get the results you want.
It is recommended to use the FindItemWithText method if you only want to find the relevant lines based on the text:
ListViewItem Lvitem = This.lv1.FindItemWithText ("Mathematics", true, 0);
The error-prone method of ListView in C #