I have 2 forms. Form1 contains a list box and a button that says update. If the user selects a number from the list box and clicks the update button then form2 pops up. Then the user can enter a number in form2 and click the update button. I want the number that the use enters to be updated in the list box. For example: form1 list box contains 1,2,3. If the user decides they want to change the number 2, they select it and click update button. When form2 pop's up the user enters the number 90 instead of 2. Finally when they click update I want the listbox in form1 to update to 90 (still keeping the other numbers).
This is what I have so far but I'm getting errors in my for loop that I'm not sure how to fix. I don't understand why I'm getting errors for my selected item in my for loop because when I looked it up thats what I found for listbox selections. Can someone please help me out? Thanks.
C#:
//FORM 1 CODE
private void btnUpdate_Click(object sender, EventArgs e)
{
Form UpdateScore = new UpdateScore();
DialogResult update = UpdateScore.ShowDialog();
if (update == DialogResult.OK)
{
for (listBox1.SelectedItem.Item)
{
listbox1.Items.Add(txtScore.Tag);
}
}
}
C#:
//FORM 2 CODE
private void btnUpdate_Click(object sender, EventArgs e)
{
this.Tag = txtScore.Text;
this.DialogResult = DialogResult.OK;
}
This is what I have so far but I'm getting errors in my for loop that I'm not sure how to fix. I don't understand why I'm getting errors for my selected item in my for loop because when I looked it up thats what I found for listbox selections. Can someone please help me out? Thanks.