Solved

Control Subforms in tabs

Posted on 2009-05-14
2
230 Views
Last Modified: 2012-05-06
I have a form with a menu tool bar across the top.
The form contains multiple tabs containing instances of a sub-form.
How can I implement the buttons in the toolbar on the active subform rather than on the last one that is displayed.
0
Comment
Question by:SarahAm
2 Comments
 
LVL 11

Expert Comment

by:Agarici
ID: 24393643
not sure i understand your question...
but, if what you want is to create a UserControl that has a toolBar inside it (on the top for instance), all you need to do is create that control, add a toolstrip (system.windows.forms.ToolStrip) to it and then add buttons to this toolstrip (system.windows.forms.ToolstripButton)

hth,
A.
0
 

Accepted Solution

by:
SarahAm earned 0 total points
ID: 24404832
No that's not it. What I want is to have one toolbar that controls the forms in each tab.
I found a solution to it, I initialized the common functions i want to implement on all types of sub-forms as interface, and it solved the problem. And i changed the implementation from tabs to MDI child forms.
I can't find the website i found the solution on, but the code is below.
Thanks
public partial class MDIParentForm : Form
{
    //tool strip menu click event
    private void whoIsActiveToolStripMenuItem_Click(object sender, EventArgs e)
    {
        if (this.ActiveMdiChild != null)
        {
            IChildForm childForm = (IChildForm)this.ActiveMdiChild;
            MessageBox.Show(childForm.GetStr());
        }
    }
}
 
interface IChildForm
{
    string GetStr();
}
 
public partial class MDIChildForm1 : Form, IChildForm
{
    public string GetStr()
    {
        return "MDIChildForm1";
    }
}
 
public partial class MDIChildForm2 : Form, IChildForm
{
    public string GetStr()
    {
        return "MDIChildForm2";
    }
}

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question