I'm working on a football related project in C#, winForms. I'm trying to make an update button which opens another window. this is my class
public class Match
{
public string team1 { get; set; }
public string team2 { get; set; }
public string pariu { get; set; }
public float cota { get; set; }
public DateTime data { get; set; }
}
This is in Form1
List<Match> m = new List<Match>();
//UPDATE
private void btEdit_Click(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count != 0)
{
Match p = m.ElementAt(listView1.SelectedIndices[0]);
Form2 edit = new Form2(p);
DialogResult dialogResult = edit.ShowDialog();//this is everytime = cancel
if (dialogResult == DialogResult.OK)
{
PopulateListView();//so this never happens
}
}
}
this is form2
private void button2_Click(object sender, EventArgs e)
{
this.Close();//cancel
}
private void button1_Click(object sender, EventArgs e)
{
match.team1 = textBox1.Text;
match.team2 = textBox2.Text;
float.TryParse(textBox3.Text, out float value);
match.cota = value;
this.Close();//save edit
}
Why do I get everytime when I update something in my listView, showDialog = 'Cancel'?