How would I say, detect specific text in a listbox and replace it with specific text. Eg:
private void timer1_Tick(object sender, EventArgs e)
{
if(listBox1.Text.Contains("Hi"))
{
// replace with Hello
}
}
In a WinForm ListBox, the Text property contains the text of the currently selected item.
(I assume that you have all string items)
If you need to find an item's text and change it with something different you need only to find the index of the item in the Items collection and then replace directly the actual text with the new one.
Note also that IndexOf returns -1 if the string is not present, so no need to add another check to find if the string is in the list or not
In
WinForms
, you could do it like this: