Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Control Subforms in tabs

Posted on 2009-05-14
2
Medium Priority
?
240 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

963 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