0

下面显示的相应 MouseDown 事件的等效 vb.net 代码是什么(C#)?我应该如何在 vb.net 中实现这个事件?

提前谢谢你,Goicox

var model = new PlotModel("MouseDown HitTestResult", "Reports the index of the nearest point.");

var s1 = new LineSeries();
s1.Points.Add(new DataPoint(0, 10));
s1.Points.Add(new DataPoint(10, 40));
s1.Points.Add(new DataPoint(40, 20));
s1.Points.Add(new DataPoint(60, 30));
model.Series.Add(s1);
s1.MouseDown += (s, e) =>
            {
                model.Subtitle = "Index of nearest point in LineSeries: " + Math.Round(e.HitTestResult.Index);
                model.InvalidatePlot(false);
            };
4

2 回答 2

1

简单的转换应该做到这一点:

Dim model = New PlotModel("MouseDown HitTestResult", "Reports the index of the nearest point.")

Dim s1 = New LineSeries()
s1.Points.Add(New DataPoint(0, 10))
s1.Points.Add(New DataPoint(10, 40))
s1.Points.Add(New DataPoint(40, 20))
s1.Points.Add(New DataPoint(60, 30))
model.Series.Add(s1)
s1.MouseDown += Function(s, e) 
model.Subtitle = "Index of nearest point in LineSeries: " &         Math.Round(e.HitTestResult.Index)
model.InvalidatePlot(False)

End Function

资料来源: http: //www.developerfusion.com/tools/convert/csharp-to-vb/

于 2013-06-21T16:03:17.087 回答
0

您需要使用 VB 'Sub' lambda(在 VS 2010 及更高版本中可用):

AddHandler s1.MouseDown, Sub(s, e)
    model.Subtitle = "Index of nearest point in LineSeries: " & Math.Round(e.HitTestResult.Index)
    model.InvalidatePlot(False)
    End Sub
于 2013-06-21T17:59:25.397 回答