Page 1 of 1

Bar Chart Click Event?

Posted: Mon Jan 16, 2006 4:14 pm
by 9639571
Is there a way to use a click event when clicking on a bar series in a bar chart?

For example, I have a bar chart showing the number of Apples, Oranges, and Banannas. Can I click on the apples bar and have it take me to my apple inventory section?

Posted: Mon Jan 16, 2006 5:25 pm
by narcis
Hi phil1995,

Yes, you can use Clicked method in the bar series Click event as shown below to retrieve which point was clicked in the series and do whatever you need related to that value.

Code: Select all

		private void Form1_Load(object sender, System.EventArgs e)
		{
			bar1.Add(25,"Bannana");
			bar1.Add(30,"Orange");
			bar1.Add(40,"Apple");
		}

		private void bar1_Click(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			Form2 currentForm = new Form2();
			currentForm.Text=bar1.Labels[bar1.Clicked(e.X,e.Y)];
			currentForm.Show();
		}