Solved

Showing a Form as a child of a Tab seamlessly

Posted on 2007-04-03
13
220 Views
Last Modified: 2010-04-23
I am trying to migrate a VB6 project coded by somebody else into VB.NET.

The VB6 project contains a form that has many frames with many controls: total controls in the form around 200.

I want to create a separate Form for each VB6 frame in the new VB.NET project, to make the project more manageable.

But in the UI, I dont want the user to know that he is dealing with separate forms. In the main form, I want to have a tabbed interface, and when the user clicks on the Tab, I want to load the respective Form into that Tab and show it as a child of the Tab.

Is it possible ? Is this approach good ? Pls. give your suggestions. Which control can give me a tabbed interface in .NET ?
0
Comment
Question by:rajesh_khater
  • 4
  • 3
  • 3
  • +1
13 Comments
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 18842773
Sounds like what you really want is a user control for each tab. This will allow you to create a layout that can be compiled and dragged onto your tab in the designer, just as you desire.

The biggest difference will be that you don't have all of the extra overhead items that come with the form (the maximize, minimize and close buttons for example)

If you're using VS2005, there's a "TabControl" control that should help with the layout.
0
 
LVL 85

Accepted Solution

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

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
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 18843584
Now, Bob.... you don't really expect to get points for the same code in both questions from the same poster??
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

 
LVL 63

Assisted Solution

by:Fernando Soto
Fernando Soto earned 250 total points
ID: 18843603
Hi rajesh_khater;

This will show a form inside a tab page of a tab control seamlessly, without any frame border.

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

Fernando
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 18843621
G'morning Chaosian!

It's Mike by the way.  Bob is "TheLearnedOne".  =)

I know there are two questions.  I have posted in both as I don't know which one will be deleted...this one is technically "older".
0
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 18843654
Yeah... as soon as I saw the notification, I realized it wasn't TheLearnedOne posting... too fast on the trigger, I guess. Sorry 'bout that.
0
 
LVL 1

Author Comment

by:rajesh_khater
ID: 18843890
I have not abandoned this question.
The other question is more specific. This question is more broad.

Anyway, if you want, pls. reduce the points of each to 250.
0
 
LVL 1

Author Comment

by:rajesh_khater
ID: 18843922
Is this a good approach ? That is, showing a form inside a tabcontrol. I am doing this to break one large form into several medium-sized manageable forms, but to give the illusion of a single form to the user .
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 18844010
I don't see a problem with it...

0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 18844090
There is not technical reason why you can't do this and it does solve your need.
0
 
LVL 1

Author Comment

by:rajesh_khater
ID: 18853083
What about common event handlers for controls in different forms ?

Earlier in one large monolithic form, I could write a common event handler. Is it possible for several controls spread across multiple forms too ?

And passing variables to and fro between forms.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 18853120
Sure it's possible...you can use AddHandler() to wire up controls with common event handlers.

Pass across forms is also possible...you just need to pass references to the forms amongst each other or make the forms raise events that the main form captures and passes on to the other forms.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

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…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
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…

829 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