Reference controls from another form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Taryon

    Reference controls from another form

    Consider the Form A calling the Form B. In the Form B i need to access the
    values of the Form A textbox.
    Normally i create the textbox as public. BUT in this case, the textbox of
    Form A will be created on the fly and i cant use the MODIFIERS.
    Anyone has an idea how to do it?


  • Lloyd Sheen

    #2
    Re: Reference controls from another form

    Create a public variable (or property) in Form B. When you create Form B
    set the property to the textbox. That will give full access to the control.

    Lloyd Sheen

    "Taryon" <taryon@fluxwir e.com> wrote in message
    news:%23wcN7MJ0 DHA.404@tk2msft ngp13.phx.gbl.. .[color=blue]
    > Consider the Form A calling the Form B. In the Form B i need to access the
    > values of the Form A textbox.
    > Normally i create the textbox as public. BUT in this case, the textbox of
    > Form A will be created on the fly and i cant use the MODIFIERS.
    > Anyone has an idea how to do it?
    >
    >[/color]


    Comment

    • Taryon

      #3
      Re: Reference controls from another form

      I cant. Remember i cannot access the textbox because it is in the Form A.
      the caller form.
      This is all i want.


      "Lloyd Sheen" <sqlguyremoveal lofthis@tostops pamhotmail.com> wrote in message
      news:MAZIb.2521 33$ea%.55871@ne ws01.bloor.is.n et.cable.rogers .com...[color=blue]
      > Create a public variable (or property) in Form B. When you create Form B
      > set the property to the textbox. That will give full access to the[/color]
      control.[color=blue]
      >
      > Lloyd Sheen
      >
      > "Taryon" <taryon@fluxwir e.com> wrote in message
      > news:%23wcN7MJ0 DHA.404@tk2msft ngp13.phx.gbl.. .[color=green]
      > > Consider the Form A calling the Form B. In the Form B i need to access[/color][/color]
      the[color=blue][color=green]
      > > values of the Form A textbox.
      > > Normally i create the textbox as public. BUT in this case, the textbox[/color][/color]
      of[color=blue][color=green]
      > > Form A will be created on the fly and i cant use the MODIFIERS.
      > > Anyone has an idea how to do it?
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Taryon

        #4
        Re: Reference controls from another form

        oh. i understand.
        let me try.
        thanks
        "Lloyd Sheen" <sqlguyremoveal lofthis@tostops pamhotmail.com> wrote in message
        news:MAZIb.2521 33$ea%.55871@ne ws01.bloor.is.n et.cable.rogers .com...[color=blue]
        > Create a public variable (or property) in Form B. When you create Form B
        > set the property to the textbox. That will give full access to the[/color]
        control.[color=blue]
        >
        > Lloyd Sheen
        >
        > "Taryon" <taryon@fluxwir e.com> wrote in message
        > news:%23wcN7MJ0 DHA.404@tk2msft ngp13.phx.gbl.. .[color=green]
        > > Consider the Form A calling the Form B. In the Form B i need to access[/color][/color]
        the[color=blue][color=green]
        > > values of the Form A textbox.
        > > Normally i create the textbox as public. BUT in this case, the textbox[/color][/color]
        of[color=blue][color=green]
        > > Form A will be created on the fly and i cant use the MODIFIERS.
        > > Anyone has an idea how to do it?
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Taryon

          #5
          Re: Reference controls from another form

          I cannot do it. can you give an example?
          i create in the FORM2 a:

          public static TextBox tb1;

          and in the form1 i have:

          private void tb_DoubleClick( object sender, System.EventArg s e)
          {
          TextBox tb = (TextBox)sender ;
          Form frm = createForm(frmn x++);
          < in this point i try to find the frm.tb1 but i cannot see it.
          frm.ShowDialog( );

          the create form is:

          private Form createForm(int ix)
          {
          tabela frm = new tabela();
          frm.Name = "frm"+ix.ToStri ng();
          frm.Tag= ix;
          return frm;
          }

          I created one public static array structure to hold the fields and its
          values. This struct i can see from FORM2.
          but i need to know what textbox is calling the form.


          "Lloyd Sheen" <sqlguyremoveal lofthis@tostops pamhotmail.com> wrote in message
          news:MAZIb.2521 33$ea%.55871@ne ws01.bloor.is.n et.cable.rogers .com...[color=blue]
          > Create a public variable (or property) in Form B. When you create Form B
          > set the property to the textbox. That will give full access to the[/color]
          control.[color=blue]
          >
          > Lloyd Sheen
          >
          > "Taryon" <taryon@fluxwir e.com> wrote in message
          > news:%23wcN7MJ0 DHA.404@tk2msft ngp13.phx.gbl.. .[color=green]
          > > Consider the Form A calling the Form B. In the Form B i need to access[/color][/color]
          the[color=blue][color=green]
          > > values of the Form A textbox.
          > > Normally i create the textbox as public. BUT in this case, the textbox[/color][/color]
          of[color=blue][color=green]
          > > Form A will be created on the fly and i cant use the MODIFIERS.
          > > Anyone has an idea how to do it?
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • Lloyd Sheen

            #6
            Re: Reference controls from another form

            From what I see in your code you may have the following problem. You are
            using a generic Form as the variable. Since the Form class has no knowledge
            of the public variable tb1 it will for sure not show in intellisence. What
            you are doing is late binding. I am more familiar with VB.NET but I would
            make all forms implement an interface with one method which sets the textbox
            into the form. Then call this method after the form is created to populate
            the variable.

            Lloyd Sheen


            "Taryon" <taryon@fluxwir e.com> wrote in message
            news:e2hfs5K0DH A.1304@TK2MSFTN GP10.phx.gbl...[color=blue]
            > I cannot do it. can you give an example?
            > i create in the FORM2 a:
            >
            > public static TextBox tb1;
            >
            > and in the form1 i have:
            >
            > private void tb_DoubleClick( object sender, System.EventArg s e)
            > {
            > TextBox tb = (TextBox)sender ;
            > Form frm = createForm(frmn x++);
            > < in this point i try to find the frm.tb1 but i cannot see it.
            > frm.ShowDialog( );
            >
            > the create form is:
            >
            > private Form createForm(int ix)
            > {
            > tabela frm = new tabela();
            > frm.Name = "frm"+ix.ToStri ng();
            > frm.Tag= ix;
            > return frm;
            > }
            >
            > I created one public static array structure to hold the fields and its
            > values. This struct i can see from FORM2.
            > but i need to know what textbox is calling the form.
            >
            >
            > "Lloyd Sheen" <sqlguyremoveal lofthis@tostops pamhotmail.com> wrote in[/color]
            message[color=blue]
            > news:MAZIb.2521 33$ea%.55871@ne ws01.bloor.is.n et.cable.rogers .com...[color=green]
            > > Create a public variable (or property) in Form B. When you create Form[/color][/color]
            B[color=blue][color=green]
            > > set the property to the textbox. That will give full access to the[/color]
            > control.[color=green]
            > >
            > > Lloyd Sheen
            > >
            > > "Taryon" <taryon@fluxwir e.com> wrote in message
            > > news:%23wcN7MJ0 DHA.404@tk2msft ngp13.phx.gbl.. .[color=darkred]
            > > > Consider the Form A calling the Form B. In the Form B i need to access[/color][/color]
            > the[color=green][color=darkred]
            > > > values of the Form A textbox.
            > > > Normally i create the textbox as public. BUT in this case, the textbox[/color][/color]
            > of[color=green][color=darkred]
            > > > Form A will be created on the fly and i cant use the MODIFIERS.
            > > > Anyone has an idea how to do it?
            > > >
            > > >[/color]
            > >
            > >[/color]
            >
            >[/color]


            Comment

            Working...