Results 1 to 11 of 11

Thread: [RESOLVED]Help Newbie in MDI form

  1. #1

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Post [RESOLVED]Help Newbie in MDI form

    Currently i'm trying to design a maintenance system required vb.net platform.
    However, i'm new of vb.net. I faced some problem that was different with vb6.Now i was added a mdiform, but i couldn't display child form at the front most of page. it is mdiform cannot add in any label and treeview? because i plan to use treeview as my menu.


    thanks for any senior and professional vb.net programmer to give me a help
    Last edited by nUflAvOrS; Jul 25th, 2007 at 06:17 AM. Reason: RESOLVED

  2. #2
    Frenzied Member circuits2's Avatar
    Join Date
    Sep 2006
    Location
    Kansas City, MO
    Posts
    1,027

    Re: Help Newbie in MDI form

    You problem is somewhat vague or under-defined. Let's start with a few of the basics of MDI and see if that helps you understand a little better.

    MDI stands for Multiple Document Interface. Essentially, you start with a main form, or a form that you wish to show other forms within. The main form is known as the MdiContainer or the MdiParent. You have to start by setting the IsMdiContainer property of the form to TRUE. This adds an MdiContainer control to your form that is docked in Fill mode. It is this container that houses the other forms that you wish to show.

    As I mentioned, your main form is known as the MdiParent. Forms that are displayed within the MdiParent are known as the MdiChildren. Lets use an example that creates two forms, Form1 and Form2. Form1 will be our main form with the IsMdiContainer property set to TRUE. You can display Form2 within Form1 using similar code to this:

    vb Code:
    1. Public Class Form1
    2.  
    3.      Public Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    4.  
    5.           ' This code creates and displays Form2
    6.           Dim myForm2 As New Form2
    7.           myForm2.MdiParent = Me
    8.           myForm2.Show()
    9.           myForm2.Dock = DockStyle.Fill
    10.  
    11.      End Sub
    12.  
    13. End Class


    Now, if your MdiContainer already contains an open MdiChild, then you can either leave the child open and set it's visible property to FALSE, or you can close all open MdiChildren. Let's modify the example code above to close all MdiChildren before opening another form, we'll say Form3:

    vb Code:
    1. Public Class Form1
    2.  
    3.      Public Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    4.  
    5.           ' This code creates and displays Form2
    6.           Dim myForm2 As New Form2
    7.           myForm2.MdiParent = Me
    8.           myForm2.Show()
    9.           myForm2.Dock = DockStyle.Fill
    10.  
    11.      End Sub
    12.  
    13.      Public Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
    14.  
    15.           ' This code will close the MdiChild Form2
    16.           For Each frm As Form In Me.MdiChildren
    17.                frm.Close()
    18.           Next
    19.  
    20.           ' This code creates and displays Form3
    21.           Dim myForm3 As New Form3
    22.           myForm3.MdiParent = Me
    23.           myForm3.Show()
    24.           myForm3.Dock = DockStyle.Fill
    25.  
    26.      End Sub
    27.  
    28. End Class
    Show the love! Click (rate this post) under my name if I was helpful.

    My CodeBank Submissions: How to create a User Control | Move a form between Multiple Monitors (Screens) | Remove the MDI Client Border | Using Report Viewer with Visual Studio 2012 Express

  3. #3

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Re: Help Newbie in MDI form

    Thanks circuits2 ... u gave me a lot of cognitive..

    i had tried your solution against my problem. however the problem still exist.
    i captured screen for showing my problem..


    Code:
    Private Sub ItemChosen(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TVMainMenu.DoubleClick
            Dim frmNewUser As New frmNewUser
            Dim frmLogin As New frmLogin
            Dim TVMainMenu As TreeNode = CType(sender, Windows.Forms.TreeView).SelectedNode
    
            If TVMainMenu.GetNodeCount(False) = 0 Then 'it is 'last' in the line 
                Dim TVtext As String
                TVtext = TVMainMenu.Text
                Select Case (TVtext)
                    Case "Create New User"
                        
                        frmNewUser.MdiParent = Me
                        frmNewUser.Show()
                        frmNewUser.Dock = DockStyle.Fill
    
                    Case "Change Password"
                    Case "Log off"
                        If MessageBox.Show("Do you want log off to another user ?", "Log off?", MessageBoxButtons.YesNo) = DialogResult.Yes Then
                            
                            frmLogin.Show()
                            Me.Hide()
                            frmNewUser.Hide()
                        End If
    
                    Case "Exit System"
                        If MessageBox.Show("Do you want to exit the program ?", "Exit Program?", MessageBoxButtons.YesNo) = DialogResult.Yes Then
                            End
                        End If
                End Select
    
    
            End If
        End Sub



    Thanks !

  4. #4
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: Help Newbie in MDI form

    Hi,

    I think your problem is that you need to split your Main Menu Page form first.
    Put your Treeview in the Left part the Childforms will be showing in the Right part of your main menu page form.

    Wkr,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  5. #5

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Re: Help Newbie in MDI form

    Thanks sparrow1,
    Do you mean that set up the loadlocation of the childform that do not touch the margin of treeview.
    Note: Treeview is attaching on parent mdiform.

  6. #6
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: Help Newbie in MDI form

    Quote Originally Posted by nUflAvOrS
    Thanks sparrow1,
    Do you mean that set up the loadlocation of the childform that do not touch the margin of treeview.
    Note: Treeview is attaching on parent mdiform.
    Hi,

    That means that both will load properly without covering each other.
    You doesn't need to set Topmost for your childforms.

    Wkr,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  7. #7

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Re: Help Newbie in MDI form

    Thanks Sparrow1,

    i think that I catch up your meaning.


    Help me to interpret if it ;-)
    add 1 more childform for attaching treeview as the menu


    Furthermore, may i know the method to ensure merely one childform loaded when calling out the same form.

    Thanks "-)

  8. #8
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: Help Newbie in MDI form

    Quote Originally Posted by nUflAvOrS
    Thanks Sparrow1,

    i think that I catch up your meaning.


    Help me to interpret if it ;-)
    add 1 more childform for attaching treeview as the menu


    Furthermore, may i know the method to ensure merely one childform loaded when calling out the same form.

    Thanks "-)
    Hi,

    You doesn't need to add one more childform for attaching your treeview, place your treeview into the splitter and call then your childforms, who will be showing up in the container. Don't forget to set IsMDIContainer = true

    Wkr,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  9. #9

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Re: Help Newbie in MDI form

    Well Sparrow1 !!
    Thx u a lot.. u had solved my problem..
    i will rate ur post :-)
    thanks ur kindness


    Can you help me again ?
    May i know the method to ensure merely one childform loaded when calling out the same childform. "-)
    Last edited by nUflAvOrS; Jul 25th, 2007 at 05:14 AM.

  10. #10
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: Help Newbie in MDI form

    Quote Originally Posted by nUflAvOrS
    Well Sparrow1 !!
    Thx u a lot.. u had solved my problem..
    i will rate ur post :-)
    thanks ur kindness
    Hi,

    No problem glad to help

    Mark your thread as resolved!

    Wkr,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  11. #11
    Frenzied Member circuits2's Avatar
    Join Date
    Sep 2006
    Location
    Kansas City, MO
    Posts
    1,027

    Re: Help Newbie in MDI form

    Quote Originally Posted by nUflAvOrS
    Can you help me again ?
    May i know the method to ensure merely one childform loaded when calling out the same childform. "-)
    You can do something like this:

    Code:
    Dim cancelAction As Boolean = False
    
    For Each frm As Form In Me.MdiChildren
         If TypeOf frm Is Form3 Then
              cancelAction = True
         End If
    Next
    
    If Not cancelAction Then
     ' Code to create new form here
    End If
    Show the love! Click (rate this post) under my name if I was helpful.

    My CodeBank Submissions: How to create a User Control | Move a form between Multiple Monitors (Screens) | Remove the MDI Client Border | Using Report Viewer with Visual Studio 2012 Express

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width