How do you set a variable value from another form?

Posted by flavour404 on Stack Overflow See other posts from Stack Overflow or by flavour404
Published on 2010-03-21T02:16:13Z Indexed on 2010/03/21 2:21 UTC
Read the original article Hit count: 464

Filed under:
|
|
|

Hi,

c# .Net 3.5 visual studio 2008, windows xp

I have a main form in a project, given a specific set of circumstances another form is instantiated and displayed to the user:

Form frmT = new frmTargetFolder(expName, this); frmT.Show();

As you can see, I am passing a reference to the new form from the current one. My question is, what do I have to do to a method so that it is exposed to the new form, the same for a variable?

I have tried defining the functions as public, but I can't seem to access them, also I have written a Get and Set method for a variable, again how do I expose these functions and methods to other forms?

public void hit()
    {
        MessageBox.Show("hit it");
    }


bool setOverRide
    {
        get
        {
            return OverRide;
        }
        set 
        {
            OverRide = value;

        }
    } 

The main form is called frmDataXfer and the form, form which I am trying to call the functions and methods of frmDataXfer is called frmTargetFolder, an instance of which is created in the frmDataXfer and referenced as frmT.

Thanks, R.

© Stack Overflow or respective owner

Related posts about c#

Related posts about visual