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
Solved

Form inside TabControl (not the other way round)

Posted on 2007-04-03
6
240 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
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
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.

 
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 85

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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

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 …
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
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…

856 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