繁体   English   中英

Vb.net相当于C#

[英]Vb.net equivalent of C#

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

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM