How I can add Items from two textBoxes and a radioButton (there are two but only one can be checked) to a listbox if you perfomed a click on a button?
This is my code:
listBox1.Items.Clear();
for (int i = 1; i < listBox1.Items.Count; i++)
{
if (textBox1.Text == listBox1.Items[i].ToString())
{
equal1 = true;
}
else
{
equal1 = false;
break;
}
}
if (equal1 == false)
{
listBox1.Items.Add(textBox1.Text);
}
for (int i = 1; i < listBox1.Items.Count; i++)
{
if (textBox2.Text == listBox1.Items[i].ToString())
{
equal2 = true;
}
else
{
equal2 = false;
break;
}
}
if (equal2 == false)
{
listBox1.Items.Add(textBox2.Text);
}
if (radioButton1.Checked == true)
{
listBox1.Items.Add("Male");
}
else if (radioButton2.Checked == true)
{
listBox1.Items.Add("Female");
}
I want those items to be added with no blank space between them because this what I get:
