Your question is a bit puzzling: if you want to delete an item from a ListView,
why do you want to move it to the top of the ListView first ?
'FindItemWithText' works fine, and you can just call foundItem.Remove(); to delete the item, after you've checked you have a non-null result of your search.
And, I do wonder here if your goal is to actually delete the item, or simply to remove it from being displayed ... possibly so you can add it back to the ListViewItems later ?
Assuming there's a reason you want to move the ListViewItem to the top of the ListView: I'm going to talk about the much more interesting issue of how to do that:
You have located what, in my humble opinion, is a flaw in the old ListView control: setting TopItem will only have an effect if the item you set to TopItem is scrolled out of view in the current ListView. This seems very stupid because ListView also supports the 'EnsureVisible' method on a ListViewItem which will make sure the ListViewItem is made visible, if scrolled out of view.
You can use this instead:
private ListViewItem foundItem;
private void button1_Click(object sender, EventArgs e)
{
foundItem = listView1.FindItemWithText(textBox1.Text);
if (foundItem != null)
{
listView1.Items.Remove(foundItem);
listView1.Items.Insert(0, foundItem);
}
else
{
}
}
May I suggest you consider not using the TextChanged event of the TextBox to trigger your search: because it's going to perform a new search each time any key on the keyboard is pressed.
If you don't want to trigger the search by a button press (as in the example code above), you might consider looking at TextBox properties like 'AcceptsReturn' and thinking about a strategy based on defining some key-down Event that triggers the search when it recognizes Return/Enter has been pressed (which is kind of a convention).