1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Rep Power

    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();
    Form A:

    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
    form...nothing changes!!!


    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
    manager... Mmhhhh...???

    Hope u can help me...

  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Rep Power
    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:
    private void Form_Closing(object sender, System.ComponentModel.CancelEventArgs e)
    	e.Cancel = true;
    To close the application call Application.Exit() or close all your child and parent forms.

    As for why your code isn't working, I'd need to see more of it.

IMN logo majestic logo threadwatch logo seochat tools logo