R
RFleming
I am a pretty experienced VB programmer trying to make a jump to C#.
I have created a simple (so I thought) project and seem to be stuck.
I know I can create a form and write the code within the form.
However just for the experience I created a Main class and created an
instance of frmMain. Using the designer I created a button btexit.
When the button is pushed I am trying to dispose the loaded instance
of frmMain. I am getting the following error and Internet searches
don't seem to address my particular issue. The error message is:
Only assignment, call, increment, decrement, and new object
expressions can be used as a statement
Example of my code:
Main.cs Below
*******************************************
using System;
using System.Windows.Forms;
using System.Text;
class MainClass
{
public static void Main()
{
TCPIPServer.frmMain frmMain1 = new TCPIPServer.frmMain();
frmMain1.Show();
Application.Run();
}
}
*********************************************
frmMain.cs below
*********************************************
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace TCPIPServer
{
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
}
private void btExit_Click(object sender, EventArgs e)
{
this.Parent.Parent.Dispose;
}
}
}
}
**********************************************
Any help, suggestion as to why or why not I would want to even
approach loading a form that way, etc.... would be greatly
appreciated!
Thanks
Ryan
I have created a simple (so I thought) project and seem to be stuck.
I know I can create a form and write the code within the form.
However just for the experience I created a Main class and created an
instance of frmMain. Using the designer I created a button btexit.
When the button is pushed I am trying to dispose the loaded instance
of frmMain. I am getting the following error and Internet searches
don't seem to address my particular issue. The error message is:
Only assignment, call, increment, decrement, and new object
expressions can be used as a statement
Example of my code:
Main.cs Below
*******************************************
using System;
using System.Windows.Forms;
using System.Text;
class MainClass
{
public static void Main()
{
TCPIPServer.frmMain frmMain1 = new TCPIPServer.frmMain();
frmMain1.Show();
Application.Run();
}
}
*********************************************
frmMain.cs below
*********************************************
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace TCPIPServer
{
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
}
private void btExit_Click(object sender, EventArgs e)
{
this.Parent.Parent.Dispose;
}
}
}
}
**********************************************
Any help, suggestion as to why or why not I would want to even
approach loading a form that way, etc.... would be greatly
appreciated!
Thanks
Ryan