Vb.C#的净当量

本文关键字:Vb | 更新日期: 2023-09-27 18:19:36

下面显示的相应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);
            };

Vb.C#的净当量

简单的转换应该做到:

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/

您需要使用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
相关文章:
  • 没有找到相关文章