Tenho este código:
Não sei o que faz esse flag, alguém pode me explicar? E na onde item recebe valor p/ comparar com o textBox?
Código:
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Replace(" ", "") != "") { bool flag = false; foreach(string item in listBox1.Items) { if (textBox1.Text.ToUpper() == item.ToUpper()) { flag = true; break; } } if(!flag) listBox1.Items.Add(textBox1.Text); } else MessageBox.Show("Campo Vazio!!"); }
Comment