How to pass values from one form to another form (Windows Application)


Good day. I want to pass the values from one Windows form to another windows form (The values in one form must be available to all the forms). Can you please suggest me the way to do it with code ?

Advance ThanX for your time & patience.



  • Kishore

    There are many ways you can do this. If you are using MDI forms you can use the ParentForm property which returns a form object:

    If you are not using MDI forms you may want to pass the form through a constructor to the newly created form:
    public class MainForm : System.Windows.Forms.Form {
    MyForm formX;

    //code ..., contructors and such

    public void OpenNewForm() {
    formX = new MyForm(this);

    public class MyForm : System.Windows.Forms.Form {
    MainForm masterForm;

    public MyForm(Form form) {
    masterForm = (MainForm) form;

    Hope this helps.

    [size=3][italic]Eric Maino[/italic][/size]
    [b][blue]GVSU[/blue] Microsoft SA[/b]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion