Solved

Form inside TabControl (not the other way round)

Posted on 2007-04-03
6
244 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

688 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