Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Link combo box to chart

$
0
0

Hello everyone, I have a question regarding c# windows forms.

I'm trying to bind the combo box with the chart.

Here is my code for the chart:

        private void button1_Click(object sender, EventArgs e)
        {
            this.chart1.Series["Fruits"].Points.AddXY("Apple", 19);
            this.chart1.Series["Fruits"].Points.AddXY("Orange", 13);
            this.chart1.Series["Fruits"].Points.AddXY("Grape", 12);
            this.chart1.Series["Fruits"].Points.AddXY("Guava", 17);
            this.chart1.Series["Fruits"].Points.AddXY("Peach", 9);
        }

So when I pressed the button, this chart will appear. How do I code it so that when user choose the different year range, the chart will appear according to the year range that the user chose?

combo box code: 

            comboBox1.Items.Add(new Item("1999", 2));
            comboBox1.Items.Add(new Item("2000", 3));
            comboBox1.Items.Add(new Item("2001", 4));
            comboBox1.Items.Add(new Item("2002", 5));
            comboBox1.Items.Add(new Item("2003", 6));
            comboBox1.Items.Add(new Item("2004", 7)); 

and 

            comboBox2.Items.Add(new Item("1999", 2));
            comboBox2.Items.Add(new Item("2000", 3));
            comboBox2.Items.Add(new Item("2001", 4));
            comboBox2.Items.Add(new Item("2002", 5));
            comboBox2.Items.Add(new Item("2003", 6));
            comboBox2.Items.Add(new Item("2004", 7));



Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>