?
Solved

Form inside TabControl (not the other way round)

Posted on 2007-04-03
6
Medium Priority
?
246 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:K V
ID: 18843267
use user controls
0
 
LVL 21

Expert Comment

by:K V
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:K V
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 1200 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 800 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

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
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…
Suggested Courses
Course of the Month8 days, 9 hours left to enroll

764 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