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);
}
}
当我使用deleteDisplayGamesListView_SelectedIndexChanged方法时,我需要将ListView控件上面的值传递给以下文本框。
private void deleteDisplayGamesListView_SelectedIndexChanged(object sender, EventArgs e)
{
deleteModifyHomeTeamTxt.Text = "";
deleteModifyHomeScoreUpDown.Text = "";
deleteModifyAwayTeamTxt.Text = "";
deleteModifyAwayScoreUpDown.Text = "";
foreach (Game currentgame in footballLeagueDatabase.games);
{
?-----------------------------
}
}
另外我需要在插入文本框后清除该行,我从ListView控件中选择了该文本框。
如果你知道怎么做,请告诉我。
答案 0 :(得分:0)
您应该可以在deleteDisplayGamesListView
事件处理程序中访问SelectedIndexChanged
。
这可让您访问ListViewItem
及其SubItem
s。