[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 :)
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:
Public Class Form1
Public Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' This code creates and displays Form2
Dim myForm2 As New Form2
myForm2.MdiParent = Me
myForm2.Show()
myForm2.Dock = DockStyle.Fill
End Sub
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:
Public Class Form1
Public Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' This code creates and displays Form2
Dim myForm2 As New Form2
myForm2.MdiParent = Me
myForm2.Show()
myForm2.Dock = DockStyle.Fill
End Sub
Public Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
' This code will close the MdiChild Form2
For Each frm As Form In Me.MdiChildren
frm.Close()
Next
' This code creates and displays Form3
Dim myForm3 As New Form3
myForm3.MdiParent = Me
myForm3.Show()
myForm3.Dock = DockStyle.Fill
End Sub
End Class
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
http://img402.imageshack.us/img402/8...capturerb9.jpg
Thanks ! :thumb: :)
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
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.
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
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 "-)
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
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. "-)
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 :wave:
Mark your thread as resolved!
Wkr,
sparrow1
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