Solved

Control Subforms in tabs

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Library to convert HTML to PDF. 8 55
MVC5 Dataformat String for Phone not working 3 25
LINQ - C# to VB convertion 12 45
Authentication of Web Services 3 46
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
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…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

929 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

8 Experts available now in Live!

Get 1:1 Help Now