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 }
原文地址:https://www.cnblogs.com/VueDi/p/12654241.html
时间: 2024-12-29 12:10:02