Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Control Subforms in tabs

Posted on 2009-05-14
2
Medium Priority
?
237 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: 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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

719 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