Share Buttons From MDI Form to all child Forms

Lets say i have an MDI Form with 3 buttons on top. Is there any way to share these buttons to all child forms but to trigger a different event depending which child form is active?

3 Replies

SK Senthil Kumaran Rajan Syncfusion Team August 20, 2018 11:16 AM UTC

Hi Nikos, 

Thank you for contacting Syncfusion support.
 
 
We hope your requirement is to fire the Button click event based in the ActiveMDIChild, if so this can be achieved by ensuring the child form with the ActiveMdiChild property of the form in the button click event. Please make use of the below code example. 

[Code Example C#]
 
 
 
private void buttonAdv1_Click(object sender, EventArgs e) 
{ 
            Form activeChild = this.ActiveMdiChild; 
 
            if (activeChild != null && activeChild == child1) 
            { 
                MessageBox.Show("Active MDI Child is : " + activeChild.Text); 
            } 
} 
 
 
We have prepared the sample for your reference and it can be downloaded from below location. If we have misunderstood your query, please provide some additional details about the reported behavior, it will be helpful for us to analyze and provide the prompt solution at the earliest. 
 
 
Regards, 
Senthil 



NI Nikos August 20, 2018 05:06 PM UTC

Let me give you an example. I have an MDI Parent Form with 3 buttons on top. Add/Edit/Delete. Also i have 3 child forms that all have a datagridview. I want to share these 3 buttons on alla 3 child forms so when i press Add while Child Form 2 is active it will open another popup form to add a new entry.


SK Senthil Kumaran Rajan Syncfusion Team August 21, 2018 11:22 AM UTC

Hi Nikos, 
 
Thank you for the update. 
We have prepared the sample based on the reported requirement. We have added 3 buttons in the main form and added the items in the DataGridView on button click by ensuring the active child form. We have to check the activeChild form and assign the value to the dataGridView in that form. Please check the below solution and let us know whether the provided solution helps to achieve the reported requirement? 
 
 
Regards, 
Senthil 


Loader.
Up arrow icon