views:

54

answers:

4

Hi 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. cheers

A: 

i have 4 teams already in the combo boxes. that is the data source. please help!!

Richard Nixon
A: 

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.

Arsenal
A: 

iv never used events before. could you give me any help? I have 9 columns in the second listview (Team, Played, Won, Lost, Draw, For, Against, GD, Points) and a button which will update the second listview at the bottom of the form.

Richard Nixon
A: 

Could you give me any examples of this please?? help would be much appreciated.

Richard Nixon