如何将一个列表视图链接到另一个列表视图以创建足球联赛表?
我正在 Windows 窗体 C# 中创建一个足球系统。我有一个输入数据的列表视图。我有 4 列,其中 2 列的团队名称链接到组合框,2 列的分数链接到数字上下控件。有 3 个按钮用于添加结果、删除和清除。代码如下:
private void addButton_Click(object sender, EventArgs e)
{
{
ListViewItem item = new ListViewItem(comboBox1.SelectedItem.ToString());
item.SubItems.Add(numericUpDown1.Value.ToString());
item.SubItems.Add(numericUpDown2.Value.ToString());
item.SubItems.Add(comboBox2.SelectedItem.ToString());
listView1.Items.Add(item);
}
}
private void clearButton_Click(object sender, EventArgs e)
{
listView1.Items.Clear();
}
private void removeButton_Click(object sender, EventArgs e)
{
foreach (ListViewItem itemSelected in listView1.SelectedItems)
{
listView1.Items.Remove(itemSelected);
}
}
我有另一个列表视图,我想将第一个列表视图链接到。第二个是常见的英国足球联赛表,我想用数学来计算所参加的比赛和积分等。请帮忙。
I am creating a football system in Windows forms C#. I have one listview where data is entered. I have 4 columns, 2 with team names linked to combo boxes and 2 with the scores linked to numericupdown controls. There are 3 buttons to add the results, Remove and clear. The code is below:
private void addButton_Click(object sender, EventArgs e)
{
{
ListViewItem item = new ListViewItem(comboBox1.SelectedItem.ToString());
item.SubItems.Add(numericUpDown1.Value.ToString());
item.SubItems.Add(numericUpDown2.Value.ToString());
item.SubItems.Add(comboBox2.SelectedItem.ToString());
listView1.Items.Add(item);
}
}
private void clearButton_Click(object sender, EventArgs e)
{
listView1.Items.Clear();
}
private void removeButton_Click(object sender, EventArgs e)
{
foreach (ListViewItem itemSelected in listView1.SelectedItems)
{
listView1.Items.Remove(itemSelected);
}
}
I have another listview that I want to link the first one to. The second one is a usual English football league table and I want to use maths to add up the games played and the points etc. Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
处理事件怎么样?
每次修改第一个列表视图中的项目(添加/删除项目)时,都会引发一个事件。
在事件处理程序中,您只需重新计算所有所需的值并将它们放置在第二个列表视图中。
How about working with events?
You throw an event everytime an item in the first Listview is modified, are an item is added/removed.
In the event handler you simple recalculate all the wanted values and place them in the second listview.