[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Showing a Form as a child of a Tab seamlessly

Posted on 2007-04-03
13
Medium Priority
?
238 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 1000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 64

Assisted Solution

by:Fernando Soto
Fernando Soto earned 1000 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 64

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

649 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