Dear Sir,
I have an error `Error 'Public Event Click As EventHandler' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.` when convert C# to VB.NET
Please Guide me
Thanks
Code in C#
private void init_Tick(object sender, EventArgs e)
{
this.init.Stop();
Form frm = base.FindForm();
frm.FormBorderStyle = FormBorderStyle.None;
if (!this.IsInDesignMode())
{
EventHandler eventHandler = null;
foreach (Component component in this.EnumerateComponents(base.FindForm()))
{
if (component.GetType() == typeof(XFormDock))
{
XFormDock docker = (XFormDock)component;
docker.TitleBarOptions.TitleBarControl = this;
this.btnMin.Click += delegate(object s, EventArgs b)
{
docker.WindowState = XFormDock.FormWindowStates.Minimized;
};
this.btnMax.Click += delegate(object s, EventArgs b)
{
docker.WindowState = ((docker.WindowState == XFormDock.FormWindowStates.Normal) ? XFormDock.FormWindowStates.Maximized : XFormDock.FormWindowStates.Normal);
};
Control control = this.btnClose;
EventHandler value;
if ((value = eventHandler) == null)
{
value = (eventHandler = delegate(object s, EventArgs b)
{
frm.Close();
});
}
control.Click += value;
break;
}
}
this.btnMin.Visible = frm.MinimizeBox;
this.btnMax.Visible = frm.MaximizeBox;
if (!this.btnMax.Visible)
{
this.pnlMin.Left = this.btnMax.Left;
}
if (this.IconClick != null)
{
this.imgIcon.Cursor = Cursors.Hand;
}
this.lblTitle.Left = ((this.imgIcon.Image == null) ? this.imgIcon.Left : this.lblTitle.Left);
}
}
Code in VB.NET
Private Sub init_Tick(ByVal sender As Object, ByVal e As EventArgs)
Me.init.Stop()
Dim frm As Form = MyBase.FindForm()
frm.FormBorderStyle = FormBorderStyle.None
If Not Me.IsInDesignMode() Then
Dim eventHandler As EventHandler = Nothing
'EventHandler <>9__2;
For Each component As Component In Me.EnumerateComponents(MyBase.FindForm())
If component.GetType() Is GetTypeXFormDock) Then
Dim docker As XFormDock = CType(component, XFormDock)
docker.TitleBarOptions.TitleBarControl = Me
AddHandler btnMin.Click, Sub(s As Object, b As EventArgs)
docker.WindowState = XFormDock.FormWindowStates.Minimized
End Sub
AddHandler btnMax.Click, Sub(s As Object, b As EventArgs)
docker.WindowState = (If(docker.WindowState = XFormDock.FormWindowStates.Normal, XFormDock.FormWindowStates.Maximized, XFormDock.FormWindowStates.Normal))
End Sub
Dim control As Control = Me.btnClose
Dim value As EventHandler
value = eventHandler
If value Is Nothing Then
eventHandler = Sub(s As Object, b As EventArgs)
frm.Close()
End Sub
value = eventHandler
End If
'Error Below Line Code
control.Click += value
Exit For
End If
Next component
Me.btnMin.Visible = frm.MinimizeBox
Me.btnMax.Visible = frm.MaximizeBox
If Not Me.btnMax.Visible Then
Me.pnlMin.Left = Me.btnMax.Left
End If
If Me.IconClickEvent IsNot Nothing Then
Me.imgIcon.Cursor = Cursors.Hand
End If
Me.lblTitle.Left = (If(Me.imgIcon.Image Is Nothing, Me.imgIcon.Left, Me.lblTitle.Left))
End If
End Sub