Pass the values from ListView control to text boxes in c#
- by Kumu
private void deleteDisplayGamesButton_Click(object sender, EventArgs e)
{
//Game game = new Game(homeTeamComboBox.Text, int.Parse(homeScoreUpDown.Value.ToString()), awayTeamComboBox.Text, int.Parse(awayScoreUpDown.Value.ToString()));
deleteDisplayGamesListView.Items.Clear();
deleteDisplayGamesListView.View = View.Details;
foreach (Game currentgame in footballLeagueDatabase.games)
{
ListViewItem row = new ListViewItem();
row.SubItems.Add(currentgame.HomeTeam.ToString());
row.SubItems.Add(currentgame.HomeScore.ToString());
row.SubItems.Add(currentgame.AwayTeam.ToString());
row.SubItems.Add(currentgame.AwayScore.ToString());
deleteDisplayGamesListView.Items.Add(row);
}
}
I need to pass the values from above ListView control to following text boxes when I use the deleteDisplayGamesListView_SelectedIndexChanged method.
private void deleteDisplayGamesListView_SelectedIndexChanged(object sender, EventArgs e)
{
deleteModifyHomeTeamTxt.Text = "";
deleteModifyHomeScoreUpDown.Text = "";
deleteModifyAwayTeamTxt.Text = "";
deleteModifyAwayScoreUpDown.Text = "";
foreach (Game currentgame in footballLeagueDatabase.games);
{
?-----------------------------
}
}
Futhermore I need to clear this data from the ListView Control.
If you know how to do this please let me know.