[英]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.