Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help....My forms won't close

Status
Not open for further replies.

Darci

IS-IT--Management
Jul 23, 2002
37
0
0
US
Hi,

I have a MDI form that contains two children. One of the children calls another form that basically pops up and shows additional information about a machine. I want to be able to close the pop up form from the child form when the user selects a different machine in a combo box ....I can't seem to get it to work.

Can someone help?

Darci
 
I have not had a chance to test what I am about to say but here goes I am sure it will be worth a try.

Why don't you on the SelectionChangeCommitted event of the combo just set the DialogResult of the form to Ok?
 
Hi,


I have copied code from another thread below.....and this should help me solve my problem....but as I have never worked with modules or threads...I am not sure how to implement this into my application.

I need to click on form3....close form2 and open form1...so I now have form 3 and form1 open in my MDIparent. Any suggestions on some modification of the below?
Darci

To run a form in it's own thread do this:

1. Import System.Threading

2. Declare all your new Forms and the thread in a module module, e.g

Public objForm1 as new Form1
Public objForm2 as new Form2
Public objForm3 as new Form3
Public objForm4 as new Form4
Public objForm5 as new Form5
Public ObjForm6 as new Form6
Public th1 as threading.thread

3. Make a sub procedure to start a Form, e.g

Private sub StartForm2()
Try
me.close()
Catch ex as ThreadAbortException
'do nothing
End Try
End Sub


4. In the button_click method for the button to open the form, do this:

th1 = new thread(AddressOf StartForm2)
th1.Priority=Priority.BelowNormal
th1.Start


That should solve your problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top