Solved

Showing a Form as a child of a Tab seamlessly

Posted on 2007-04-03
13
226 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
[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
  • 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 86

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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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 86

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 86

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 86

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

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 …
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

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