Re: Accessing parent controls in an MDI form fom the child forms by their name



Hello, Raj,

To access a control by name I think that you will have to search (recursively) through all controls until you find the one(s) that match the name you want.

To accomplish your ultimate goal (enabling/disabling menu items based on the current state of the application) I suggest that you reverse the responsibility. I.e. put the code to enable/disable child menu items in a handler for the parent menu's Popup event.

Cheers,
Randy


raj_genius wrote:
I hav two queries, whc are as follows:
FIRSTLY:
is it possible to access the controls(by name) of a parent form(MDI)
from its child forms??if yes then how??plzz provide a coded example in
VB if possible..

for example..i hav a menu in the parent form named "Administrator" whic
has an item "mnuLogIn"..now when i click on login..another child form
named "frmLogIn" is displayed..what i want to happen is this:
when login form(frmLogIn) is opened, the corresponding menu option in
the parent form (i.e menu option "mnuLogIn") should get disabled..and
when i close the "frmLogIn" child form..the menu item "mnuLogIn" in the
parent form should again be enabled.

so..what shud i write in the child form's(frmLogIn's) "closed" event
and "load" event..so tht it enables and disbles the corresponding menu
item(mnuLogIn) in the parent form's menu on these two events
respectively??

I ALREADY KNOW HOW TO DO THIS USING THE INDEX OF THE PARENT MENU
ITEM(i.e. by using Me.ParentForm.Menu.MenuItems(0).Enabled = False
..etc..)..but i want a way in whc i can access those menu items by
name..for example if the parent form's menu item's name is "mnuLogIn" ,
then i want to access it by the same name in the child form so that i
can chage the properties of the item in the parent form.is it
possible??if yes..i want the coded solution..if not,then why??


SECONDLY:
i hav an xml file whc has some database connectivity parameters, how
can i access them in a VB windows form??i mean how can i access data in
xml files in windows application?
suppose i hav the <connection string> , <database name> etc..as xml
values in an xml file..and i want tht evrytime i create a
connection/make a transaction, my applications reads these connection
parameters from this xml file instead of i specifying that in code and
establishes the connection/executes the query...can any1 show in VB
code how to do that??can any1 suggest a better way to store this
information in any other file other than XML..say in a text file..and
then the application can access and read necessary data by searching
for it in the file?

i hope some1 will take his time, interest and effort to answer my
queries..whc might be very easy for many..thanx
Raj

.



Relevant Pages

  • Re: Saving dataset as nested XML
    ... my child is nested but I only received the duplicate ... > table, your code worked, and the resulting XML file had the data nested. ... > resulting schema from the file, and pasted it back into the XSD Editor. ... > parent and the child tables both contains the parent ID field, ...
    (microsoft.public.dotnet.xml)
  • RE: Accessing parent controls in an MDI form fom the child forms by th
    ... for example..i hav a menu in the parent form named "Administrator" whic ... i hav an xml file whc has some database connectivity parameters, ...
    (microsoft.public.dotnet.general)
  • RE: Join key of table
    ... The VBA program assigns a number to the parent form before going to the child ... Product Support Group which, apparently, wants $250.00 to answer my question. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Saving dataset as nested XML
    ... I originally had the child table nested. ... table, your code worked, and the resulting XML file had the data nested. ... installing most likely SP1 help too. ... parent and the child tables both contains the parent ID field, ...
    (microsoft.public.dotnet.xml)
  • Re: C# beginners question
    ... Your parent form needs to check the result of the child dialog and then act ...
    (microsoft.public.dotnet.languages.csharp)