473,320 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

mdi forms do not dispose [original post to Controls, by mistake]

* Apologies .. this is a duplicate of a msg posted in the Controls forum,
where I posted it first by mistake -- Jeremy

My mdi child has a shared execute method which creates and shows it. I'm
attempting to limit the number of instances of this specific child to 1.
When I close the form, it visibly goes away, but it remains in memory.
ComboBox events fire for every supposedly "closed" instance of
frmMyMDIchild. Obviously there is either a nasty bug in VB, or I completely
misunderstand something very basic. Help me out here!

- Jeremy

Public Class frmMyMDIchild
Inherits System.Windows.Forms.Form
Shared frm As frmMyMDIchild = Nothing
Private ImDead As Boolean = False 'for debugging

Public Shared sub Execute(mdiParent as Form)
If frm Is Nothing Then
frm = New frmMyMDIchild
With frm
.midParent = mdiParent
'Do some inits ...
End With
End If
frm.Show()
End Function

Private Sub frmMyMDIchild_Closed(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Closed
Me.ImDead = True
frm.Dispose()
frm = Nothing
End Sub

Private Sub cbMyDropDown_SelectedValueChanged(ByVal sender as Object, ByVal
e As System.EventArgs) Handles cbMyDropDown.SelectedValueChanged
'This fires even for instances of frm where ImDead is True. ie: the
"Closed" frms are not closed at all.
msgbox(iif(ImDead,"Dead","Not Dead"))
End Sub

'** end **

Nov 21 '05 #1
1 1071
Here's a curious additional fact. In my combobox, I'm using a datatable
from a Class as a datasource. If I simply populate the combobox in the ide
with a few items, the mdi forms actually seem to dispose when I say
"dispose". Here's the original code that sets up the combobox:

private sub setupComboBox

dim tbl as DataTable

'myTables is an instance of a class that persists after the form is
closed.
tbl = myTables.dsTables.Tables("KindOfGrain")
cbKindOfGrain.ValueMember() = tbl.Columns("CodeName").ColumnName
cbKindOfGrain.DisplayMember() = tbl.Columns("Kind").ColumnName
cbKindOfGrain.DataSource = tbl

end sub

I'm truly going nuts over this!

Jeremy

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: adam | last post by:
I have 2 forms. Form1 has two buttons. When i click button1 i would like form2 to open and show some objects on the form as visible. If i click button2 i would like to set these objects visible...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
15
by: Wiktor Zychla | last post by:
today we've found a critical issue regarding the ListView from Windows.Forms. it was confirmed on several machines with Win2K and XP. here's the problem: create a ListView with about 50000 rows....
7
by: Mike Bulava | last post by:
I have created a base form that I plan to use throughout my application let call the form form1. I have Built the project then add another form that inherits from form1, I add a few panel controls...
17
by: Joshua Kendall | last post by:
I have a splash screen that is set to a timer. When the timer reaches it's Interval of 1000, I want it to load the next form in my project. My brother knows VB6 from school but can't figure out...
15
by: Joshua Kendall | last post by:
I have a script in which it keeps opening the same form instead of only one instance. I also need help with a form that has a password. Where do I put the actual password? can I use a database for...
7
by: Sergey Poberezovskiy | last post by:
Hi, I created two base forms: frmList and frmDetail, compiled them into a dll, and then want to use in my new project. The problem: When I created new inherited form, say frmClients, I cannot...
3
by: Geraldine Hobley | last post by:
Hello, In my project I am inheriting several forms. However when I inherit from a form and add additional subroutines and methods to my inherited form I get all sorts of problems. e.g. I sometimes...
21
by: Dan Tallent | last post by:
In my application I have a form (Customer) that I want to be able to open multiple copies at once. Within this form I have other forms that can be opened. Example: ZipCode. When the user enters...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.