C# code

Discussion in 'C#' started by Nirmal, Nov 3, 2011.

  1. Nirmal

    Nirmal New Member

    Joined:
    Oct 21, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    I have a two forms in C# windows application .I want to control the component from first form the control are placed in second form?
     
  2. moonface

    moonface New Member

    Joined:
    Nov 4, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    I think you shoud just type if you want to control form 1 to form2
    type form2.show
    me.hide
     
  3. imported_Troy

    imported_Troy New Member

    Joined:
    Jan 2, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Home Page:
    http://onenetworks.us
    Okay, take the constructor of the second form and make it:
    Code:
    FirstForm firstForm;
    public SecondForm(FirstForm _first) {
    firstForm = _first;
    }
    
    // do whatever to firstForm's controls. (Make sure the controls or whatever you are accessing is public.)
    
    Now when you declare SecondForm in FirstForm, use it like this:
    Code:
    void ShowSecondForm() {
    SecondForm sf = new SecondForm(this);
    sf.Show();
    }
    
    There you go. I hope that's what you wanted.
     
  4. jaunjbaker

    jaunjbaker New Member

    Joined:
    Jun 25, 2012
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Manager
    Location:
    Boca Raton, FL 33428
    It would be nice if you provide some more information about C# windows application.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice