delegate VB.Net等效代碼 高手的問題
C#: void ClickTest( ToolStripButton tmp, string str1)
{ }
ToolStripButton tmp = new ToolStripButton();
tmp.ImageTransparentColor = System.Drawing.Color.Magenta;
tmp.Name = "toolbarSave";
tmp.Text = "Save";
tmp.Click += delegate
{
ClickTest(tmp, "Clicktest");
};
VB.Net 的等效代碼應該是怎麼樣的(紅色部份)??
------最佳解决方案--------------------Lz写得太乱,看了半天才看明白是啥。
private void Form1_Load(object sender, EventArgs e)
{
ToolStripButton tmp = new ToolStripButton();
tmp.ImageTransparentColor = System.Drawing.Color.Magenta;
tmp.Name = "toolbarSave";
tmp.Text = "Save";
toolStrip1.Items.Add(tmp);
tmp.Click += delegate
{
ClickTest(tmp, "Clicktest");
};
}
void ClickTest( ToolStripButton tmp, string str1)
{
this.Text = "100";
}
等效的VB代码:
Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim tmp As ToolStripButton
tmp = New ToolStripButton
tmp.ImageTransparentColor = System.Drawing.Color.Magenta
tmp.Name = "toolbarSave"
tmp.Text = "Save"
AddHandler tmp.Click, AddressOf _Click
End Sub
Sub ClickTest(ByVal tmp As ToolStripButton, ByVal str1 As String)
Me.Text = 100
End Sub
Private Sub _Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
ClickTest(sender, "Clicktest")
End Sub
------其他解决方案--------------------