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

Howdy, Stranger!

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


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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

kishore_peddikishore_peddi Posts: 176Member


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.



  • emainoemaino Posts: 48Member

    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.