Pass the values from ListView control to text boxes in c#

Posted by Kumu on Stack Overflow See other posts from Stack Overflow or by Kumu
Published on 2010-04-29T06:15:46Z Indexed on 2010/04/29 6:17 UTC
Read the original article Hit count: 306

Filed under:

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.

© Stack Overflow or respective owner

Related posts about c#