C#

Moderators: None (Apply to moderate this forum)
Number of threads: 2720
Number of posts: 5746

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
How to pass values from one form to another form (Windows Application) Posted by kishore_peddi on 24 Sept 2003 at 9:17 AM

Hi,

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.

Cheers,
Kishore
Report
Re: How to pass values from one form to another form (Windows Applicat Posted by emaino on 24 Sept 2003 at 8:39 PM
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:
this.ParentForm;


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 {
     //variables
     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.





Eric Maino
GVSU Microsoft SA




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.