Accessing form objects from other forms. 
Author Message
 Accessing form objects from other forms.

In VB6, you could access controls and objects on a form from another form
easily like:

Assuming you have Form1 and Form2.

If you are in Form2,
    and Form1 is loaded,
        you could set the Form1.TextBox1.text property using:

Form1.TextBox1.Text =  Me.Caption

Is there anyway to do something like this in VB.Net. I am currently putting
all my form object (as Public) in a module called FormsModule. Then I access
them from other forms using:

FormsModule.Form1.TextBox1.Text = Me.Caption

Is there a better way to do this?



Sat, 02 Apr 2005 02:40:30 GMT  
 Accessing form objects from other forms.
In VB7, there is no default shared reference to your form instance. If you
want it, you will have to declare it yourself.

That's what you are doing with your Module and I think that's a correct way
to do it. Another way would be to define a
    public shared m_Form1Instance as Form1
in your Form1 and set this reference in the constructor of the Form
    m_Form1Instance = me

Tarik and Yannick.

--
This posting is provided "AS IS" with no warranties, and confers no rights.

Quote:
> In VB6, you could access controls and objects on a form from another form
> easily like:

> Assuming you have Form1 and Form2.

> If you are in Form2,
>     and Form1 is loaded,
>         you could set the Form1.TextBox1.text property using:

> Form1.TextBox1.Text =  Me.Caption

> Is there anyway to do something like this in VB.Net. I am currently
putting
> all my form object (as Public) in a module called FormsModule. Then I
access
> them from other forms using:

> FormsModule.Form1.TextBox1.Text = Me.Caption

> Is there a better way to do this?



Sat, 02 Apr 2005 03:40:54 GMT  
 Accessing form objects from other forms.
Thank you.



Quote:
> In VB7, there is no default shared reference to your form instance. If you
> want it, you will have to declare it yourself.

> That's what you are doing with your Module and I think that's a correct
way
> to do it. Another way would be to define a
>     public shared m_Form1Instance as Form1
> in your Form1 and set this reference in the constructor of the Form
>     m_Form1Instance = me

> Tarik and Yannick.

> --
> This posting is provided "AS IS" with no warranties, and confers no
rights.


> > In VB6, you could access controls and objects on a form from another
form
> > easily like:

> > Assuming you have Form1 and Form2.

> > If you are in Form2,
> >     and Form1 is loaded,
> >         you could set the Form1.TextBox1.text property using:

> > Form1.TextBox1.Text =  Me.Caption

> > Is there anyway to do something like this in VB.Net. I am currently
> putting
> > all my form object (as Public) in a module called FormsModule. Then I
> access
> > them from other forms using:

> > FormsModule.Form1.TextBox1.Text = Me.Caption

> > Is there a better way to do this?



Sat, 02 Apr 2005 09:09:20 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Accessing Objects on a Mdi Parent form from a Mdi Child form

2. Open form, close form, open form = disposed object exception

3. Linking Form Objects in HTML to other Form Objects using VBScript

4. Access Forms collection, App object or Global object of the Parent application

5. Making Form appear on top of others.

6. Tax Forms & others

7. Problem: Two forms swap each others taskbar buttons

8. object on form to return form to sender

9. update an db embedded word object with contents form a form

10. Modifying object in MDI Parent form from MDI Child form

11. Scaling forms/form objects to fit various monitors.

12. VBSCRIPT - Set the value of form object before form posting

 

 
Powered by phpBB® Forum Software