Solved

Showing a Form as a child of a Tab seamlessly

Posted on 2007-04-03
13
218 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
Comment Utility
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
Comment Utility
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
Comment Utility
Now, Bob.... you don't really expect to get points for the same code in both questions from the same poster??
0
 
LVL 62

Assisted Solution

by:Fernando Soto
Fernando Soto earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Author Comment

by:rajesh_khater
Comment Utility
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
Comment Utility
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
Comment Utility
I don't see a problem with it...

0
 
LVL 62

Expert Comment

by:Fernando Soto
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now