473,657 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB.NET HELP required on MDI child forms

3 New Member
Mdi Container - frmMdiContainer
Child Form - frmChildForm

however in my frmChildForm, i have a button to open another form - frmSpecial. In order to open frmSpecial in the frmMdiContainer (like a child like frmChildForm). This is what i did in my frmChildForm.
Expand|Select|Wrap|Line Numbers
  1. Dim frmSpecial AS SpecialForm
  2.  
  3. frmSpecial.MdiParent = Me.MdiParent
  4. frmSpecial.WindowState = FormWindowState.Maximized
  5. frmSpecial.Show()
  6. ' More Codes to be executed after frmSpecial closes '
  7. MessageBox.show("frmSpecial shld be close")
  8. ' More Codes to be executed after frmSpecial closes '
The problem is, the frmSpecial shows and disappears immediately and the messagebox pops up. This is not what i wanted.

How can I make the frmSpecial modal in the mdi container? showdialog() does not work. The messagebox shld pop up after i have close the frmSpecial. But currently it opens and closes itself immediately. I need the frmSpecial to stay open after frmSpecial.Show () as i need to fill up information in the form and use in my frmChildForm.
Nov 21 '08 #1
4 3414
nukefusion
221 Recognized Expert New Member
To get your message box to pop up after frmSpecial closes you will need to handle the FormClosed event. Some code like the following should work:

Expand|Select|Wrap|Line Numbers
  1.  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         Dim specialForm As frmSpecial
  3.         specialForm = New frmSpecial()
  4.         specialForm.MdiParent = Me.MdiParent
  5.         specialForm.WindowState = FormWindowState.Maximized
  6.         AddHandler specialForm.FormClosed, AddressOf specialForm_FormClosed
  7.         specialForm.Show()
  8.     End Sub
  9.  
  10.     Private Sub specialForm_FormClosed(ByVal sender As Object, ByVal e As FormClosedEventArgs)
  11.         ' Codes to be executed after frmSpecial closes
  12.         MessageBox.Show("Test")
  13.     End Sub
I don't think there's any way you can set frmSpecial to be a "modal" MDI child but you can simulate that behaviour by looping all MDI children and setting them to "Enabled = false". Then in the FormClosed event where you show the message box, loop all children again and set them to "Enabled = true".
Nov 21 '08 #2
blurboy
3 New Member
Mdi Container - frmMdiContainer
Child Form - frmChildForm

however in my frmChildForm, i have a button to open another form - frmSpecial. In order to open frmSpecial in the frmMdiContainer (like a child like frmChildForm). This is what i did in my frmChildForm.
Expand|Select|Wrap|Line Numbers
  1. Dim frmSpecial AS SpecialForm
  2.  
  3. frmSpecial.MdiParent = Me.MdiParent
  4. frmSpecial.WindowState = FormWindowState.Maximized
  5. frmSpecial.Show()
  6. ' More Codes to be executed after frmSpecial closes '
  7. MessageBox.show("frmSpecial shld be close")
  8. ' More Codes to be executed after frmSpecial closes '
The problem is, the frmSpecial shows and disappears immediately and the messagebox pops up. This is not what i wanted.

How can I make the frmSpecial modal in the mdi container? showdialog() does not work. The messagebox shld pop up after i have close the frmSpecial. But currently it opens and closes itself immediately. I need the frmSpecial to stay open after frmSpecial.Show () as i need to fill up information in the form and use in my frmChildForm.
Nov 24 '08 #3
nukefusion
221 Recognized Expert New Member
You are correct. Execution won't stop at the specialForm.Sho w() method. The form is shown and the program keeps on running.
If you use ShowDialog() then execution will pause at that point (as you were expecting) until the form closes, but as you pointed out ShowDialog() won't work for what you are trying to do.

To get those two lines of code to run after specialForm is closed, you need to put them inside the FormClosed event, like in the following sample:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 
  2.         Dim specialForm As frmSpecial 
  3.         specialForm = New frmSpecial() 
  4.         specialForm.MdiParent = Me.MdiParent 
  5.         specialForm.WindowState = FormWindowState.Maximized 
  6.         AddHandler specialForm.FormClosed, AddressOf specialForm_FormClosed 
  7.         specialForm.Show() 
  8.     End Sub 
  9.  
  10.     Private Sub specialForm_FormClosed(ByVal sender As Object, ByVal e As FormClosedEventArgs) 
  11.         ' Codes to be executed after frmSpecial closes 
  12.   textbox.text = specialForm.object.name
  13. getNumber(specialForm.object.number)
  14. End Sub 
Nov 24 '08 #4
blurboy
3 New Member
ok i see how it works now. thanks nukefusion!
Nov 27 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
4928
by: CJack | last post by:
hy, I have an mdi application, i create a child form and I want to know when a button is pressed while that child form is loaded. I have this code: private void frmTestBaby_KeyUp(object sender, System.EventArgs e) { MessageBox.Show("keyboard button pressed!"); } Following is the code to load the frmTestBaby
2
3429
by: Jim Shank | last post by:
I am really trying to find the best OOP way of doing this. I have a parent MDI form with multiple children and I am trying to communicate variables between them. I have been able to successfully get the parent form to read the child variable by using a Public Property in one of my child forms like such: Public ReadOnly Property ID() As String Get Return strID End Get
6
9415
by: Edwinah63 | last post by:
Hi everyone, could someone give me some thoughts on the best way to manage mdi parent and child forms? in vb6 i could scroll through the forms collection and determine which forms were open/closed and their current state. now i can't. before i didn't have to declare numerous named instances each time i loaded or unloaded a form.
10
4008
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the application. What should happen, is that the main MDI form should close, taking the child forms with it. There is code to loop through the child forms, remove the controls on each of them, and then close the form, but this code should execute only...
0
2282
by: Scott H. | last post by:
I have an MDI parent form that creates mdi child forms each of which are represented by a tab item. I use a third party control to generate the tabbed MDI child forms. Each tab or MDI child form displays information regarding a specific asset that is determined by an asset number. The asset numbers are entered through a global tool bar. I can enter an asset number and then display several MDI child forms. For example: I can display...
2
2439
by: Matt | last post by:
Ok here is my problem: I have a MDI parent form called "Main" that I declare in a public module when I start up my program. This form holds the drop down menu that allows my users to access all of the child forms. Now lets say I have a child form called "Child." When I open up that child form from "Main" I shut off the menu on "Main" so that the user cannot open up any other forms while they are in the "Child" form.
13
2935
by: Academic | last post by:
I have a MDI form, sometimes child forms and sometimes forms that are neither If I close the app the child forms closing and closed event happens followed by the Mdi form receiving the events.. But the regular forms that are also open do not receive that event. This is true whether there are child forms open or not.
4
2039
by: VIKKI | last post by:
hi I want to know different types way for calling child forms in a particular project.....I'm new to C# language and I'm not able to add child form in my project so plz anyone can tell me how to work wid child forms and mdi forms.......
12
6222
by: Phil | last post by:
I can check for MdiChildren.Length=0, but which event handler should I put this in to detect when a child window is closed? TIA Phil.
0
2038
by: emalcolm_FLA | last post by:
Hello and TIA for any help with this non profit Christmas assistance project. I have an applicant (app history) and child (child history) tables (4 total). I need to grab the next available (in house case number, appt date and time) for the applicants yearly history and the childs yearly history and then print a report with the applicants info and this in house case number. The forms are linked with ID_app (from the applicant table).
0
8399
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8827
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8504
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8606
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6169
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4159
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2732
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1959
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.