What I need to do is basically read some info from the my first form and then into my second third form (second one is for something else) and once I get that info close the first form, this is how Im reading from form to form:
csharp
//MainCalc is the third form and LogIn is the first form
public MainCalc(LogIn form)
{
InitializeComponent();
Owner = form;
_form = form;
}
private LogIn _form = null;
then I'm reading like this:
csharp
private void MainCalc_Load(object sender, EventArgs e)
{
string account = _form.textBox1.Text;
string name = "Hello, ";
string positon = "Position: ";
string departament = "Departament: ";
TextReader reader = new StreamReader(Application.StartupPath + "\\Users\\" + account + "\\" + "Info.txt");
while (reader.Peek() != -1)
{
reader.ReadLine();
name += reader.ReadLine();
position += reader.ReadLine();
departament += reader.ReadLine();
}
}
Now once all that is read how would I be able to close the first form i tried
_form1.Close() but that closes everything also tried to make it on the closing even but that gives me an error:
csharp
private void MainCalc_FormClosing(object sender, FormClosingEventArgs e)
{
_form.Close();
}
the error is (not a compiler one, I'm getting it once I try to close the form): An unhandled exception of type 'System.StackOverflowException' occurred in System.Windows.Forms.dll
This post has been edited by Korupt: 21 Aug, 2008 - 04:12 PM