Need help with listbox

Mar 17 2020 1:36 PM
I am pretty new to programming and I need help. I have a listbox with names and when radioButtonA is selected I need all of the names which are on an even numbered row to be copied to a textbox. When radioButton B is selected, the names on odd numbered rows should be copied in the textbox instead. However I do not know how to put the number of rows in a constant which I need. I also do not know how to copy the specific names to the textbox. The code is below.


 private void button1_Click(object sender, EventArgs e)
{
String group = "?????";
listBox1 //I want to get the number of names in the listbox on this line
int size = //I want to put the number of names from the listbox in this int constant
if (radioButtonA.Checked == true)
{
group += "A:\n\n";
for (int i = 0; i < size; i += 2)
{
group += + "\n"; //I want to add the name from the row in here
}
textBox2.Text = group;
}
else if (radioButtonB.Checked == true)
{
group += "B:\n\n";
for (int i = 1; i<size; i+= 2)
{
group += + "\n"; //I want to add the name from the row in here
}
textBox2.Text = group;
}
}

Brought to you by:

Answers (2)