Solved

Control Subforms in tabs

Posted on 2009-05-14
2
225 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now