try this, corrected code and custom search.
private void btAdd_Click(object sender, EventArgs e)
{
string nameFamily = tbName.Text + " | " + tbFamily.Text;
listnames.Items.Add(nameFamily + " | " + tbTell.Text);
}
private void btnSerch_Click(object sender, EventArgs e)
{
bool isExactNameSearch = true;
string search = tbSerch.Text.Trim();
foreach (string item in listnames.Items)
{
var parts = item.Split('|');
string name = parts[0].Trim();
string number = parts[2];
if (isExactNameSearch)
{
if (name == search)
{
MessageBox.Show(number);
break;
}
}
else {
if (name.Contains(search))
{
MessageBox.Show(number);
break;
}
}
}
}