Dialog box to access dataset in Parent

  • Thread starter Thread starter Guest
  • Start date Start date
M said:
Do I have to set Mdi information? How can I access the parent form and it's controls?


pass a reference of the parent to the dialog window's constructor and
expose as public properties in the parent what ever u need to access
from the child
 
Hi mark,

I guess Bijoy is suggesting this way
/////
class MyForm : Form
{
ParentForm _parent;
public MyForm (ParentForm parent)
{
_parent = parent;
}
}
/////
And as Bijoy said, if you want to access the controls in the parent form,
you need change their Modifiers to public (by default is private) Or define
a Public property to expose them.

Does it answer your question?

Best regards,

Ying-Shen Yu [MSFT]
Microsoft community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 
Hi mark,

If the Dialogbox just needs some information from the parent form for one
time,
it's a simple solution to define some public field to get these information.
You may also try defining a method to set these information into the dialog
box object to
de-couple the parent form code and the public variable.

If you have any further questions on this issue, please feel free to reply
this thread.

Best regards,

Ying-Shen Yu [MSFT]
Microsoft community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
 
Back
Top