2012-03-13 2 views

답변

2

같은 cursor.position을 잡기 위해 해당 이벤트를 수정 이 예에서와 같이 : 당신이 CursorTool를 사용하는 경우

public partial class Form1 : Form 
    { 
    public Form1() 
    { 
     InitializeComponent(); 
     InitializeChart(); 
    } 

    private void InitializeChart() 
    { 
     tChart1.Aspect.View3D = false; 
     tChart1.Series.Add(new Steema.TeeChart.Styles.Error()).FillSampleValues(); 
     tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove); 
    } 

    void tChart1_MouseMove(object sender, MouseEventArgs e) 
    { 
     Steema.TeeChart.Styles.Error error1 = (Steema.TeeChart.Styles.Error)tChart1[0]; 

     int index = error1.Clicked(e.X, e.Y); 
     string tmp = ""; 

     if (index != -1) 
     { 
     double y = error1.YValues[index]; 
     double error = error1.ErrorValues[index]; 
     double top = y + error; 
     double bottom = y - error; 
     tmp = top.ToString("#.##") + " - " + bottom.ToString("#.##"); 
     } 
     else 
     { 
     tmp = ""; 
     } 

     this.Text = tmp; 
    } 
    } 

당신에게 MouseMove 이벤트의 eX 및 EY 인수에 해당되는 CursorTool 및 전 및 도망의 축 값을 제공 e.XValue 및 e.YValue 인수가 있습니다 그래서 당신은 그 사건과 같은 간단한 예제를 할 수 있습니다 :

public Form1() 
{ 
    InitializeComponent(); 
    InitializeChart(); 
} 

private void InitializeChart() 
{ 
    tChart1.Aspect.View3D = false; 
    tChart1.Series.Add(new Steema.TeeChart.Styles.Error()).FillSampleValues(); 
    //tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove); 

    Steema.TeeChart.Tools.CursorTool cursor1 = new Steema.TeeChart.Tools.CursorTool(tChart1.Chart); 
    cursor1.Series = tChart1[0]; 
    cursor1.FollowMouse = true; 
    cursor1.Change += new Steema.TeeChart.Tools.CursorChangeEventHandler(cursor1_Change); 
} 

void cursor1_Change(object sender, Steema.TeeChart.Tools.CursorChangeEventArgs e) 
{  
    Steema.TeeChart.Styles.Error error1 = (Steema.TeeChart.Styles.Error)tChart1[0]; 

    int index = error1.Clicked(e.x, e.y); 
    string tmp = ""; 

    if (index != -1) 
    { 
    double y = error1.YValues[index]; 
    double error = error1.ErrorValues[index]; 
    double top = y + error; 
    double bottom = y - error; 
    tmp = "Error top: " + top.ToString("#.##") + 
      " Error bottom: " + bottom.ToString("#.##") + 
      " Cursor pos.: " + e.XValue.ToString("#.##") + "/" + e.YValue.ToString("#.##"); 
    } 
    else 
    { 
    tmp = ""; 
    } 

    this.Text = tmp; 
} 
+0

error1.Clicked (int, int); 내 시리즈에는 0.01, 0.02, 0.03의 레코드가 있으며 인덱스를 얻는 방법은 무엇입니까? –

+0

error1.Clicked는 이러한 값을 반환합니까? 0부터 error1.Count-1까지의 정수를 반환해야합니다. 문제가 지속되면 테스트 케이스와 함께 http://www.teechart.net/support/index.php에 게시하거나 TeeChart에 등록 된 고객이 아닌 경우 http : //www.steema에서 예제 프로젝트를 보내십시오. .net/upload /. –

+0

@ Narcis Calvet 커서 도구가 다른 CursorChangeEventArgs를 가지고 있기 때문에 cursortool의 경우 처리하는 방법을 알려 주실 수 있으며 Errorseries에 마우스 커서를 놓는 경우에만 작동합니다. cursorTool에 대한 해결 방법. 감사합니다 –

-3

저는 teechart에 익숙하지 않지만 커서를 만들 수 없다면 cursor.move 이벤트가 있다는 것을 확신합니다. 그런 다음 당신은 마우스 아래에있는 점을 알고 해당하는 값을 검색하기 위해 TeeChart는 마우스 이벤트 (예 : 13. OnMouseMove에서는)와 시리즈 '클릭 된 방법을 사용할 필요가 너무

CursorMove(object sender, args e) 
{ 

    this.lowerTextBox.value = cursor.postion; 

}