Pass Parameters between C# Forms !

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rushd2002
    New Member
    • Jul 2007
    • 1

    Pass Parameters between C# Forms !

    hi
    am using Microsoft Visual C# 2005 as the programming language.
    here what i want to do..
    when run, its mainly 1 form..(Form1)
    with some buttons..
    one of them is "Setup the Form" (which change the form appearance or add/remove some controllers in it).
    when i click the "Setup the Form" button, i made new instance of a 2nd form (Form2) .. which have some text boxes, and check boxes.

    ill ask about the simplest thing (just to get the idea!!).
    if i want to change the Form1 text (in title bar)

    i enter the new text in a textbox and i click submit.
    i want to make it like this in the buttonSubmit_Cl ick function (we still in Form2)

    Form1.Text = Form2.TextBox1. Text.ToString() .

    i get a error msg, which means that this Form (Form2) has no access to Form1 controllers !
    is there a way to do that !!!! : (

    P.S : i tried to use delegates and events.. but how can i "Fire" the event in Fom2 and handle it in Form1 !?

    any 1 have any idea !
    thanx in advance..
  • nmsreddi
    Contributor
    • Jul 2006
    • 366

    #2
    Hello

    Create an object of form one in form two then you can access

    form1 properties in form2 ,

    try it out ,it works fine

    Comment

    • Jimmy611
      New Member
      • Jan 2007
      • 49

      #3
      Make a property in form 1 and on Submit button in Form 2 pass the values to that property on form1.

      Comment

      • prabunewindia
        New Member
        • Mar 2007
        • 199

        #4
        hi friend,
        create a constructor for form1

        form1(string para1,string para2)
        {
        string name1=para1;
        string name2=para2;
        }

        now create an object for form2

        form1 f1=new form1("aaa","bb b");
        f1.open();

        thats enough.
        u can create multiple constructor for a form as like method overloading
        Prabu

        Comment

        Working...