Click here to Skip to main content
15,910,661 members
Please Sign up or sign in to vote.
3.22/5 (2 votes)
See more:
I was developing a project using vbnet and access but I fail to know how I can link multiple form and how I can make them work embedded in one form that has menus to make changes.

Please help know how I can embed those forms to display in one.
VB
' this is form that will display the every form to be updated 

Public Class LibrarySystemForm


    Private Sub welcome_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       
    End Sub


    Private Sub BookFormToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BookFormToolStripMenuItem.Click
        bookForm.Show()
    End Sub

    Private Sub AmountFormToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AmountFormToolStripMenuItem.Click
        amountForm.Show()

    End Sub

    Private Sub SupplierFormToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SupplierFormToolStripMenuItem.Click
        supplierForm.Show()
    End Sub

    Private Sub ReservationFormToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReservationFormToolStripMenuItem.Click
        reservationForm.Show()
    End Sub

    Private Sub ReturnFormToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReturnFormToolStripMenuItem.Click
        returnForm.Show()
    End Sub

    Private Sub UserdetailFormToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UserdetailFormToolStripMenuItem.Click
        user_detailForm.Show()
    End Sub


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

    End Sub

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

    End Sub

    Private Sub ToolStripContainer1_ContentPanel_Load_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripContainer1.ContentPanel.Load, ContentPanel.Load
        bookForm.Show()
    End Sub



End Class

VB
' this the code of one of the form that has to be embed in the form that has menus to be edited
Public Class supplierForm

    Private Sub SuppliersBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Validate()
        Me.SuppliersBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me._CUULibDB_mdbDataSet3)

    End Sub


    Private Sub SuppliersBindingNavigatorSaveItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SuppliersBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.SuppliersBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me._CUULibDB_mdbDataSet3)

    End Sub

    Private Sub Form7_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the '_CUULibDB_mdbDataSet3.suppliers' table. You can move, or remove it, as needed.
        Me.SuppliersTableAdapter.Fill(Me._CUULibDB_mdbDataSet3.suppliers)

    End Sub
End Class


I would like to get someone's email so that I may send to him or her the whole project to have look on it. thank u
Posted
Updated 18-Jul-13 14:40pm
v2

1 solution

Hi,
You can use panel or Tab Control on your Main form.Best is go with Tabcontrol on your main form.for example add a
Tabcontrol on your main form.
then in menu click.here i have default one tab page added in TabControl ,rest of the Tab Pages will be generated on menu click.

C#
private void newToolStripMenuItem_Click(object sender, EventArgs e)
     {


         Form2 frm = new Form2();
         frm.TopLevel = false;
         frm.Visible = true;
         frm.FormBorderStyle = FormBorderStyle.None;
         frm.Dock = DockStyle.Fill;
         tabControl1.TabPages[0].Controls.Add(frm);
     }

     private void openToolStripMenuItem_Click(object sender, EventArgs e)
     {
        Form3 frm = new Form3();
             frm.TopLevel = false;
             frm.Visible = true;
             frm.FormBorderStyle = FormBorderStyle.None;
             frm.Dock = DockStyle.Fill;

             if (tabControl1.TabPages.Count > 1)
             {

                 tabControl1.TabPages[0].Controls.Add(frm);
             }
             else
             {
                 tabControl1.TabPages.Add("Secont Tab");
                 tabControl1.TabPages[1].Controls.Add(frm);

             }
     }

     private void loadToolStripMenuItem_Click(object sender, EventArgs e)
     {
         Form3 frm = new Form3();
         frm.TopLevel = false;
         frm.Visible = true;
         frm.FormBorderStyle = FormBorderStyle.None;
         frm.Dock = DockStyle.Fill;

         if (tabControl1.TabPages.Count > 1)
         {

             tabControl1.TabPages[0].Controls.Add(frm);
         }
         else
         {
             tabControl1.TabPages.Add("Secont Tab");
             tabControl1.TabPages[1].Controls.Add(frm);

         }
     }

     private void saveToolStripMenuItem_Click(object sender, EventArgs e)
     {
         Form4 frm = new Form4();
         frm.TopLevel = false;
         frm.Visible = true;
         frm.FormBorderStyle = FormBorderStyle.None;
         frm.Dock = DockStyle.Fill;

         if (tabControl1.TabPages.Count > 2)
         {

             tabControl1.TabPages[2].Controls.Add(frm);
         }
         else
         {
             tabControl1.TabPages.Add("Third Tab");
             tabControl1.TabPages[2].Controls.Add(frm);

         }
     }
 
Share this answer
 
Comments
DAVID DUSHIMIMANA 18-Jul-13 21:19pm    
Thank you Sir for your help, but allow me to ask you something else, how should I do to make the main form recognize others forms, since form I'm using they are from access database, I added them through dragging. if possible you may send to me your email on my email address dushidav7@hotmail.com so that I send to you project to have a look on it. thank you
syed shanu 18-Jul-13 21:22pm    
Ok,If that Solution is fine for your question make it as Answered.
DAVID DUSHIMIMANA 18-Jul-13 21:33pm    
Sir, can I have your email. the one you sent to me has refused. mine is dushidav7@hotmail.com

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