I back again with yet another problem in my code.
I populate my first listbox like so:
private void addList_Click(object sender, EventArgs e)
{
List<string> _scoreboard = new List<string>();
ProSailor sailor1 = new ProSailor(1, 24, 7);
ProSailor sailor2 = new ProSailor(2, 23, 14);
ProSailor sailor3 = new ProSailor(3, 20, 5);
CharitySail sailor4 = new CharitySail(4, 210, "WWF");
CharitySail sailor5 = new CharitySail(5, 75, "Anaphylaxis Campaign");
CharitySail sailor6 = new CharitySail(6, 325, "Childs Play");
NoveltySail sailor7 = new NoveltySail(7, 210, "Games Aid", "Batman", 2);
NoveltySail sailor8 = new NoveltySail(8, 210, "Extra-Life", "Legend of Zelda", 3);
NoveltySail sailor9 = new NoveltySail(9, 210, "water", "Disney", 5);
_scoreboard.Add(sailor1.ToString());
_scoreboard.Add(sailor2.ToString());
_scoreboard.Add(sailor3.ToString());
_scoreboard.Add(sailor4.ToString());
_scoreboard.Add(sailor5.ToString());
_scoreboard.Add(sailor6.ToString());
_scoreboard.Add(sailor7.ToString());
_scoreboard.Add(sailor8.ToString());
_scoreboard.Add(sailor9.ToString());
listBox2.DataSource = _scoreboard;
}
Now I would like to transfer this data to another listbox with one of two messages!
Either:
private void btnDNF_Click(object sender, EventArgs e)
{
listBox1.Items.Add(listBox2.SelectedItem + " This Sailor Did Not Finish.");
}
Or
private void btnFinished_Click(object sender, EventArgs e)
{
listBox1.Items.Add(listBox2.SelectedItem + " They finished the race in " + textBox1.Text + " hour(s) " + textBox2.Text + " minute(s) and " + textBox3.Text + " second(s)");
}
I end up with something that says: "Sailor 1, 24 years of age has 7 races completed. They Finished the Race in 1 hour(s), 07 minute(s) and 45 second(s)" Or instead of the time, "Did Not Finish the Race."
My problem is that the number of 7 races doesn't increase to 8 when I click finished. I have no clue how to go about doing this.
Also of the numbers are stored in another class. Here is the ProSailor Class:
class ProSailor : Sailor
{
public int Age { get; set; }
public int NoOfSailsFin { get; set; }
public ProSailor(int number, int age, int noOfSailsFin)
: base(number)
{
this.Age = age;
this.NoOfSailsFin = noOfSailsFin;
}
public override string ToString()
{
return "Sailor " + Number + ", " + Age + " years of age has " + NoOfSailsFin + " races completed.";
}
Basically, I need "noOfSailsFin" to increase by 1 number when the finished button is clicked.
Also, if someone could tell me how to make it so that this outputs from one listbox to the other and then deletes/removes the item from the first listbox that would be super helpful too!
Thanks!