August 6th, 2003, 01:41 AM
Call methods from another form... and some more questions :)
I really have a stupid problem...
Imagine... I have a form A.
Within this form I call a method named setData();
formB fb= new formB();
This setData() (in form B) looks like this:
Public void setData()
this.variable="Why doesn't it work!?";
I mean it's soooooo easy... but why doesn't it work???
The debugger runs trough that all without any complaints... But on the
Btw... Why does a form sometimes close the whole application with
this.Close() and another form doesn't???
And sometime I can't close with "x"... it just hides and stays in the task
Hope u can help me...
August 6th, 2003, 02:48 PM
By default, your application has a main form, this is the form that is sent to the Application.Run() function when your application starts. When this form closes the application terminates unless another message loop (namely another form) is active.
Now pressing the 'X' button calls the Form.Close() event, which frees all the resources created with the form and disposes it. Normally you don't want to do this; you just want to hide it. To do this simply override the Closing event:
To close the application call Application.Exit() or close all your child and parent forms.
private void Form_Closing(object sender, System.ComponentModel.CancelEventArgs e)
e.Cancel = true;
As for why your code isn't working, I'd need to see more of it.