开发者

How do I link one listview to another to create a football league table?

开发者 https://www.devze.com 2022-12-28 00:01 出处:网络
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 开发者_运维知识

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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消