Solved

Form inside TabControl (not the other way round)

Posted on 2007-04-03
6
242 Views
Last Modified: 2010-04-23
I have a TabControl inside a Form. In the TabControl, I want to show another Form at runtime. How can I do this ?
0
Comment
Question by:rajesh_khater
[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
6 Comments
 
LVL 21

Expert Comment

by:theGhost_k8
ID: 18843267
use user controls
0
 
LVL 21

Expert Comment

by:theGhost_k8
ID: 18843270
form EE:

You can convert your form to a user control.  That allows you to layout all of the controls in the same way as a form, but without the non-client border, caption, and buttons.

Do you need the non-client stuff as well or are you just trying to encapsulate all of the controls that would go on a form or a tab page?  If you're doing it for encapsulation, create the user control and place one in the tab page, and you can place another on an empty form.  If you actually want the non-client area within a tab page, you might be able to paint and manage that yourself, but it would be alot of coding (painting, mouse/keyboard handling, drag drop, etc) to do it.
0
 
LVL 21

Expert Comment

by:theGhost_k8
ID: 18843271
0
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!

 
LVL 63

Accepted Solution

by:
Fernando Soto earned 300 total points
ID: 18843307
Hi  rajesh_khater;

In answer to your question, this is how to add a form control NewForm to a tab page of a tab control.

        Dim newFrm As New NewForm
        newFrm.TopLevel = False
        newFrm.Parent = TabPage1
        newFrm.WindowState = FormWindowState.Maximized
        newFrm.Show()

Fernando
0
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 18843402
Rajesh,

Check your other question on this topic -- user controls have already been recommended, along with the same limitations pointed out by theGhost.
0
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 200 total points
ID: 18843552
You can make the forms borderless and set their Dock property to Fille when you place them into the TabControl to make them "seamless"...

*** Very similar code to Fernando's post above ***

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim fa As New FormA
        ' initialize "fa" if needed...
        AddFormToTabControl(TabControl1, fa)
    End Sub

    Private Sub AddFormToTabControl(ByVal tb As TabControl, ByVal frm As Form)
        Dim tp As New TabPage
        tp.Text = "Tab" & tb.TabPages.Count + 1

        frm.TopLevel = False
        frm.FormBorderStyle = Windows.Forms.FormBorderStyle.None
        frm.Dock = DockStyle.Fill
        tp.Controls.Add(frm)
        frm.Show()

        tb.TabPages.Add(tp)
    End Sub

End Class
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying 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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

738 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