I converted a piece of code from VB to C#. The UI in VB has a button ButNewOrder. On click of the button , the below method gets executed in VB code
Public Sub mnuFileNewJob_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles ButNewOrder.Click
Dim ErrorFlag As ErrorFlagType = InitErrorFlag()
Try
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
StatusText = "Loading New Job."
LoadNewSoftJob(Me)
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default
Catch ex As Exception
ErrorFlag.NumErrors += 1
ReDim Preserve ErrorFlag.ErrorDef(ErrorFlag.NumErrors - 1)
With ErrorFlag.ErrorDef(ErrorFlag.NumErrors - 1)
.Description = "Error Loading New Job: " + ex.Message
.Number = ErrorFlag.NumErrors - 1
End With
End Try
If ErrorFlag.NumErrors > 0 Then
Dim ErrFrm As New FrmErrList
ErrFrm.ErrorFlag = ErrorFlag
ErrFrm.Show()
End If
End Sub
The above code when I convert to C#, I get this
public void mnuFileNewJob_Click(System.Object eventSender, System.EventArgs eventArgs)
{
Mold_Power_Suite.Model.FrontEndStructures.ErrorFlagType ErrorFlag = FrontEndStructures.InitErrorFlag();
try
{
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
ModSoftFrontEndGlobalVariables.StatusText = "Loading New Job.";
frmMain main = new frmMain();
MainMod.LoadNewSoftJob(this);// I think I need to replace this with the form name
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
}
catch (Exception ex)
{
ErrorFlag.NumErrors += 1;
Array.Resize(ref ErrorFlag.ErrorDef, ErrorFlag.NumErrors);
var _with1 = ErrorFlag.ErrorDef[ErrorFlag.NumErrors - 1];
_with1.Description = "Error Loading New Job: " + ex.Message;
_with1.Number =Convert.ToInt16( ErrorFlag.NumErrors - 1);
}
if (ErrorFlag.NumErrors > 0)
{
FrmErrList ErrFrm = new FrmErrList();
ErrFrm.ErrorFlag = ErrorFlag;
ErrFrm.Show();
}
}
Clicking on the Button in C# application is not resulting in anything. Double click on the button generates the following stub which means that there is nothing hooked up on the click event of the button.
private void ButNewOrder_Click(object sender, EventArgs e)
{
}
I want to know how to let my button execute the same function as that of VB code?