How to acess forms controls of one form from other in VB.NET 
Author Message
 How to acess forms controls of one form from other in VB.NET

How to acess forms controls of one form from other in VB.NET
I have a  main mdi form and other forms are called using the menu on this
forms. I want to change the values of the status bar panels  of MDI form
from the forms which are called. Now how to access this from the called
forms.

in vb6:
mdiMain.statusbar1.panele(1)= "whatevr......"

same is not working in VB.NET

thanks

dk



Tue, 22 Jun 2004 23:59:03 GMT  
 How to acess forms controls of one form from other in VB.NET
Hi dk,

The controls on Form by default declared as Private. Make it Public by
either using Modifiabilty property or in code window.

hope this helps.

...Ashok


Quote:
> How to acess forms controls of one form from other in VB.NET
> I have a  main mdi form and other forms are called using the menu on this
> forms. I want to change the values of the status bar panels  of MDI form
> from the forms which are called. Now how to access this from the called
> forms.

> in vb6:
> mdiMain.statusbar1.panele(1)= "whatevr......"

> same is not working in VB.NET

> thanks

> dk



Wed, 23 Jun 2004 00:04:39 GMT  
 How to acess forms controls of one form from other in VB.NET
hi dk,

unlike vb6, everything on forms is private, so expose anything you need
using a property. or, better yet, implement a function to write text to the
status bar and call it from the child forms... gives you better/cleaner
control over the form contents.

dushan bilbija


Quote:
> How to acess forms controls of one form from other in VB.NET
> I have a  main mdi form and other forms are called using the menu on this
> forms. I want to change the values of the status bar panels  of MDI form
> from the forms which are called. Now how to access this from the called
> forms.

> in vb6:
> mdiMain.statusbar1.panele(1)= "whatevr......"

> same is not working in VB.NET

> thanks

> dk



Wed, 23 Jun 2004 00:11:28 GMT  
 How to acess forms controls of one form from other in VB.NET
Re: Thanks for a very prompt reply. I will try what is suggested.

thanks
dk


Quote:
> hi dk,

> unlike vb6, everything on forms is private, so expose anything you need
> using a property. or, better yet, implement a function to write text to
the
> status bar and call it from the child forms... gives you better/cleaner
> control over the form contents.

> dushan bilbija



> > How to acess forms controls of one form from other in VB.NET
> > I have a  main mdi form and other forms are called using the menu on
this
> > forms. I want to change the values of the status bar panels  of MDI form
> > from the forms which are called. Now how to access this from the called
> > forms.

> > in vb6:
> > mdiMain.statusbar1.panele(1)= "whatevr......"

> > same is not working in VB.NET

> > thanks

> > dk



Wed, 23 Jun 2004 00:25:41 GMT  
 How to acess forms controls of one form from other in VB.NET
Thanks dushan
I wrote a public function (mdiMainStatusBarPanel) in mdiMain form. Indeerd
it is a very good idea. I call it from the child forms. But for calling it I
have to instintiate the mdiForm in child form

Dim frmMdiMain As mdiMain = New mdiMain()
frmMdiMain.mdiMainStatusBarPanel(1, "Connection Successful")

It goes smooth but the value is not displayed on the mdi main form. I think
I should not instintiate it again. but I dont know how to refer the mdi form
in child form whiout declaring it again.

Some more help will get me through

thanks

dk



Wed, 23 Jun 2004 01:13:15 GMT  
 How to acess forms controls of one form from other in VB.NET
Thanks dushan
I wrote a Public function (mdiMainStatusBarPanel) for changing the content
of the status bar on mdi form. when I call it from the child form, it does
not display on the mdi main form.

            Dim frmMdiMain As mdiMain = New mdiMain()
            frmMdiMain.mdiMainStatusBarPanel(2, "Connection Successful")

I feel it is because, I am creating new instance of MDI main form here. I
dont knwo how to refer the old instance of MDI main form.

Pl help.
thanks
dk


Quote:
> hi dk,

> unlike vb6, everything on forms is private, so expose anything you need
> using a property. or, better yet, implement a function to write text to
the
> status bar and call it from the child forms... gives you better/cleaner
> control over the form contents.

> dushan bilbija



> > How to acess forms controls of one form from other in VB.NET
> > I have a  main mdi form and other forms are called using the menu on
this
> > forms. I want to change the values of the status bar panels  of MDI form
> > from the forms which are called. Now how to access this from the called
> > forms.

> > in vb6:
> > mdiMain.statusbar1.panele(1)= "whatevr......"

> > same is not working in VB.NET

> > thanks

> > dk



Wed, 23 Jun 2004 01:20:23 GMT  
 How to acess forms controls of one form from other in VB.NET
Hi

Yes, you are creating a new instance of MDI main form. You must get a MDI
main form reference. How ? In this especific case, you can use ParentForm
property of MDI child to get access to MDI main form. Try this:

    CType (Me.ParentForm, mdiMain).mdiMainStatusBarPanel (2, "Connection
successful")

You can use ParentForm property because you are using MDI forms, and the
ParentForm of a MDI child form will be the MDI main form.



Quote:
> Thanks dushan
> I wrote a Public function (mdiMainStatusBarPanel) for changing the content
> of the status bar on mdi form. when I call it from the child form, it does
> not display on the mdi main form.

>             Dim frmMdiMain As mdiMain = New mdiMain()
>             frmMdiMain.mdiMainStatusBarPanel(2, "Connection Successful")

> I feel it is because, I am creating new instance of MDI main form here. I
> dont knwo how to refer the old instance of MDI main form.

> Pl help.
> thanks
> dk



> > hi dk,

> > unlike vb6, everything on forms is private, so expose anything you need
> > using a property. or, better yet, implement a function to write text to
> the
> > status bar and call it from the child forms... gives you better/cleaner
> > control over the form contents.

> > dushan bilbija



> > > How to acess forms controls of one form from other in VB.NET
> > > I have a  main mdi form and other forms are called using the menu on
> this
> > > forms. I want to change the values of the status bar panels  of MDI
form
> > > from the forms which are called. Now how to access this from the
called
> > > forms.

> > > in vb6:
> > > mdiMain.statusbar1.panele(1)= "whatevr......"

> > > same is not working in VB.NET

> > > thanks

> > > dk



Wed, 23 Jun 2004 04:22:45 GMT  
 How to acess forms controls of one form from other in VB.NET
Thanks. It worked fine. Still I want to know if there is any way to get
reference of one form from (FORM 2) other form(FORM 1) without creating the
new instance of the FORM 1. In my aplication MDI main form calls FORM 1 and
FORM1 calls FORM2. I want to refer the controls of MDI Form and Form 1 when
I am on Form 2.

Thanks once again for the help.

regards
dk



Wed, 23 Jun 2004 04:44:58 GMT  
 How to acess forms controls of one form from other in VB.NET
dk,

Why don't you create one global (project level) object for you mdi maon form
and use this everywhere you required. Since you need only one Mdi form and
that should be acceed from whoie applictaion.

Declare the public object of main mdi form in the startup.

...Ashok


Quote:
> Thanks. It worked fine. Still I want to know if there is any way to get
> reference of one form from (FORM 2) other form(FORM 1) without creating
the
> new instance of the FORM 1. In my aplication MDI main form calls FORM 1
and
> FORM1 calls FORM2. I want to refer the controls of MDI Form and Form 1
when
> I am on Form 2.

> Thanks once again for the help.

> regards
> dk



Wed, 23 Jun 2004 18:13:50 GMT  
 How to acess forms controls of one form from other in VB.NET
Ashok,

Yes, but if this is needed, it is probably best to keep it encapsulated as a
Shared/Static property of the MDIForm.

Kathleen



Thu, 24 Jun 2004 01:04:34 GMT  
 How to acess forms controls of one form from other in VB.NET
dk,

using the parent property should work. or... what i do is create an
initialize function in all child forms, and pass it a reference to the
parent form. each child form then has a reference to its parent... even if
not mdi.

*** assuming you have a frmMain variable in the form module... remember NOT
to create a new frmMain; it'll hold a reference to the form

public function initialize(byref ParentForm as MyProject.frmMain)
Set mp_frmMain = ParentForm
end function

then

dim new_ChildForm as MyProject.ChildForm
new_ChildForm.Initialize(Me)

that oughta do it nicely...

dushan


Quote:
> Thanks. It worked fine. Still I want to know if there is any way to get
> reference of one form from (FORM 2) other form(FORM 1) without creating
the
> new instance of the FORM 1. In my aplication MDI main form calls FORM 1
and
> FORM1 calls FORM2. I want to refer the controls of MDI Form and Form 1
when
> I am on Form 2.

> Thanks once again for the help.

> regards
> dk



Thu, 24 Jun 2004 05:21:34 GMT  
 
 [ 13 post ] 

 Relevant Pages 

1. how to export modules, forms in on Acess db1 to another Acess db2

2. Close one form in vb.net

3. Can anybody straighten me out on accessing one form's controls from another form

4. How refer from one form to a control in another open form

5. load another form form one form

6. Linking Records form one form to another in VB 6.0

7. exception on form.show (vb.Net windows forms)

8. VB.NET - Subclassing System.Windows.Forms.Form?

9. Integrating Visio(or any other Win32 app form) in a Vb.net Form

10. PRB: One (just one) control in a form

11. One one form based on a control value in another

12. Can i have two Winsock Controls in one VB Form

 

 
Powered by phpBB® Forum Software