欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

DEV Chart控件鼠标选中某条曲线

程序员文章站 2022-04-14 16:40:15
1 this.Chart.ObjectSelected += new DevExpress.XtraCharts.HotTrackEventHandler(this.Chart_ObjectSelected); 2 this.Chart.ObjectHotTracked += new DevExpr ......
 1   this.chart.objectselected += new devexpress.xtracharts.hottrackeventhandler(this.chart_objectselected);
 2             this.chart.objecthottracked += new devexpress.xtracharts.hottrackeventhandler(this.chart_objecthottracked);
 3             chart.selectionmode = elementselectionmode.single;
 4             //chart.seriesselectionmode = seriesselectionmode.point;
 5 
 6  public series seriesselected = null;
 7         public seriespoint pointselected = null;
 8         public object selectedanotherobject = null;
 9         bool seriesselection = true;
10 
11         protected virtual bool allowselectanotherobject(object obj)
12         {
13             return false;
14         }
15         private void chart_objectselected(object sender, hottrackeventargs e)
16         {
17             if (e.object is series)
18             {
19                 e.cancel = !seriesselection;
20                 if (seriesselection) 
21                 {
22                     this.seriesselected = (series)e.object;
23                     this.pointselected = e.additionalobject as seriespoint;
24                 }
25             }
26             else
27             {
28                 if (allowselectanotherobject(e.object))
29                 {
30                     this.selectedanotherobject = e.object;
31                     e.cancel = false;
32                 }
33                 else
34                 {
35                     this.selectedanotherobject = null;
36                     e.cancel = true;
37                     chart.clearselection(false);
38                 }
39                 if (seriesselection)
40                 {
41                     this.seriesselected = null;
42                     this.pointselected = null;
43                 }
44             }
45         }
46 
47         private void chart_objecthottracked(object sender, hottrackeventargs e)
48         {
49             if (e.object is series)
50                 e.cancel = !seriesselection;
51             else
52                 e.cancel = !allowselectanotherobject(e.object);
53         }