Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I would like to know how to use tabcontrol to display multiform,to diplay one form by one and to permit menustrip for edit or update for that form.
Basically one form is main and others are secondaries forms, they have to be displayed in that main for and be edited through menus on that same main form.

here are the code I've tried to make but didn't work. please help out. thank u
VB
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Data.OleDb
Public Class LibrarySystemForm
    Dim con As New OleDb.OleDbConnection
    Dim da As OleDb.OleDbDataAdapter
    Dim cmd As OleDbCommand
    Private Sub welcome_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim dbprovider As String = "PROVIDER=Microsoft.ACE.OleDb.12.0;"
        Dim dbsource As String = "DATA SOURCE = CUULibDB.mdb.accdb"
        con.ConnectionString = dbprovider & dbsource
        con.Open()


        
    End Sub
    Private Sub MyTabs()
        Me.TabControl1 = New TabControl()
        Me.TabPage1 = New TabPage()
        Me.TabPage2 = New TabPage()

        Me.TabControl1.Controls.AddRange(New Control() {Me.TabPage1, Me.TabPage2})
        Me.TabControl1.Padding = New Point(15, 10)
        Me.TabControl1.Location = New Point(35, 25)
        Me.TabControl1.Size = New Size(220, 220)

        ' Selects tabPage2 using SelectedTab. 
        Me.TabControl1.SelectedTab = TabPage2

        Me.TabPage1.Text = "supplierForm"
        Me.TabPage2.Text = "tabPage2"

        Me.Size = New Size(300, 300)
        Me.Controls.AddRange(New Control() {Me.TabControl1})
    End Sub

    Public Sub tab()
        MyTabs()
    End Sub

    Shared Sub Main()
        Application.Run(New supplierForm())

    End Sub

    Private Sub ToolStripContainer1_ContentPanel_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripContainer1.ContentPanel.Load

    End Sub

    Private Sub MenuStrip1_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles MenuStrip1.ItemClicked

    End Sub
End Class
Posted
Comments
DAVID DUSHIMIMANA 23-Jul-13 10:28am    
I'm using visual basic studio 2010 and access 2007 as a database
Kschuler 23-Jul-13 10:44am    
Your question is a bit confusing. I think some of the problem is just the wording you are using. There are objects called Tab Controls and they each contain a Tab Page. Are you really trying to add multiple tab controls? Or multiple tab pages? I'm also wondering if when you are using the word "form" if you are really referring to a tab page as well? Perhaps you should first start by researching the Tab Control class. Check out the MSDN link here (There are code examples if you scroll way down): http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.aspx
Also, regarding the code above...I see that you have a method called MyTabs() which seems to be doing some stuff with tab controls, but I don't see anywhere that you are calling that method except in the method tab() which is not called anywhere else. The code won't run unless you call it from somewhere...or did you just not include that code?
DAVID DUSHIMIMANA 23-Jul-13 11:21am    
Anyway, tabcontrol I m using, it is on the main form that has menus, and I have others forms due to how my access database has many tables, my question was to know how I can insert those form in tabcontrol, basically in tapages and then edit them from there through menus. that how is. I would like to know if I use the method of draging the tables, every table on each tabpage if it can work. I think I've tried to explain myself. thank u Sir. I m waiting, you can even send it through my email. [EDIT]Email has been removed, because of SPAM robots - Maciej Los[/EDIT]
Maciej Los 23-Jul-13 11:46am    
Where are you stuck? What have tried till now?
How many tabbed forms/windows do you have?
DAVID DUSHIMIMANA 23-Jul-13 16:40pm    
I'm trying to use your code but doesn't work, I think the version your are using is not like mine , I m using visual studio 2010 Express on windows 8

1 solution

I would recommend you to use SearchBox (at the right-top corner of this window). There you'll find many examples. Some of them i've listed for you here:
Tabbed MDI Child Forms[^]
Creating Tabbed MDI Form[^]
A highly configurable MDI tab control from scratch[^]
Form as Tab[^]
A Simple Tabbed MDI[^]
Easy Tabbed Mdi Interface Using the ToolStrip[^]
Tabbed MDI in WPF[^]

Is it enough for start?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900