Groups | Blog | Home
all groups > visual c > march 2005 >

visual c : Windows Forms> How to Control Main_Form from Sub_Form


Alper AKCAYOZ
3/31/2005 1:01:06 AM
Hello,

I am developing a project using Windows Forms .NET by using Visual C++ .NET
v2003.
I open a Sub_Form by clicking a button on the Main_Form. Some operations are
working at Main_Form and results of those works are updating the texts and
enable statuses of controls (LabelBox, Buttons, etc.) on the Sub_Form.
I would like to control and update the controls' text, enabled statuses at
Main_Form from Sub_Form.
Let's say my initial form is MDI type (Main_Form). It has a StatusBar and
StatusBarPanels. I open a child form (Sub_Form) by clicking menu option.
Whenever I click a button on Sub_Form, I want to inform the user by changing
the text of a StatusBarPanel on Main_Form (MDI Parent).
I thank your kind guidance in advance.
--
~~~~~~~~~~~~~~~~~~~
İyi Çalışmalar
Alper AKÇAYÖZ (Bil Muh)

Wish You Good Work
Reuben
4/2/2005 8:01:02 PM
Add a 'Parent' property/member to Sub_Form that is set through its
Alper AKCAYOZ
4/4/2005 12:09:02 AM
I think an overloaded constructor, which takes the address of Main_Form as
parameter, should be in the class of Sub_Form. Like below;

SUB_FORM.H
------------------------
#include "Main_Form.h"
....
public __gc class MDI_Child : public System::Windows::Forms::Form
{
...
public:
void Sub_Form(void)
{
InitializeComponent();
}

public:
System::Windows::Forms::Form *frmMain;

//If I state Main_Form as type of a variable, compiler gives error
//How can I include the Main_Form class into Sub_Form ???
void Sub_Form( Main_Form *frm )
{
frmMain = frm;
InitializeComponent();
}
...
}

How can I include the Main_Form class into Sub_Form ?


[quoted text, click to view]
AddThis Social Bookmark Button