2014-02-22 62 views

回答

0

加點試試這個C#代碼,它應該給你一個開始。我用它來添加文本到Label這就是顯示x值爲日期和y值作爲一個數字。希望這有助於

Chart Click GIF

public void Cht_Click(object sender, System.Windows.Forms.MouseEventArgs e) 
{ 
//Call HitTest() 
HitTestResult result = sender.HitTest(e.X, e.Y); 

//If the mouse if over a data point 
if (result.ChartElementType == ChartElementType.DataPoint) { 
    //Reset Data Point Attributes 
    DataPoint point = default(DataPoint); 

    //Find selected data point 
    point = result.Series.Points(result.PointIndex); 

    //extract x value 
    System.DateTime _date = System.DateTime.FromOADate(point.XValue); 
    Label24.Text = "Date: " + Strings.Format(_date, "dd/MM/yy") + " Value: " + point.YValues(0); 

} 

} 
+0

謝謝。 FromOADate就足夠了) – r3l0c