查找在VB 2008中图表中单击的系列项目 [英] Finding series item clicked in a chart in VB 2008

查看:90
本文介绍了查找在VB 2008中图表中单击的系列项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将VB 2008与.NET Framework的Microsoft图表控件一起使用.使用饼状图,我想在单击或双击图表时找到选定的项目.

I am using VB 2008 with the Microsoft Chart Controls for .NET Framework. Using a pie chart, I would like to find the selected item when the chart is clicked or double clicked.

我有如下所示的click和doubleclick事件,已确认已被点击,并且事件图包含单击的x,y位置.

I am have the click and doubleclick events as shown here, which I have confirmed is being hit, and the the eventarts contains the x,y position of the click.

Private Sub Chart_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs)
Private Sub Chart_Click(ByVal sender As Object, ByVal e As System.EventArgs)

我真正想发现的是单击或双击了哪个系列项(什么饼图).

What I would really like to find out is what series item was clicked or doubleclicked (what pie slice).

这是在Windows窗体应用程序中完成的.

This is being done in a windows forms application.

如何使系列项目被单击或双击?

How do I get the series item clicked or doubleclicked?

推荐答案

以下内容为您提供了鼠标下的图表元素.

The following gives you the chart element under the Mouse.

Dim HTR as HitTestResult
Dim SelectDataPoint As DataPoint

HTR = Chart1.HitTest(e.x,e.y)
SelectDataPoint = Chart1.Series(0).Points(HTR.PointIndex)

请注意,您可能应该进行一些检查,以通过检查HTR.ChartElementType来确保它是用户单击的系列.哦,这应该发生在MouseUp事件中,因为我使用的e是MouseEventArgs.

Note that you should probably do some checking to make sure it is a Series that the user clicks on by checking the HTR.ChartElementType. Oh, and this should go in a MouseUp event, since the e that I use are MouseEventArgs.

这篇关于查找在VB 2008中图表中单击的系列项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆