Click here to Skip to main content
15,920,383 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi... friends I have a window form in vb.net I show another form on button click of form1 and then form2 is display but the problem is that if I click on form1 then the form2 minimized is there any technique so the user cannot click on form1 till he close the form2 I use the following code to show the form2 on button click

VB
Private Sub btn_Search_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Search.Click
        Dim f As New form2()
        f.Show()
 End Sub

and one another thing is that it should be displayed in the center of form1, please help me..

thanks in advance
Parveen Rathi
Posted

Use Form.ShowDialog instead of Form.Show.
 
Share this answer
 
You should show the form as a Modal dialogue like this:-

VB
Private Sub btn_Search_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Search.Click
        Dim f As New form2()
        f.ShowDialog()
        ...
        ... Code to process form results
        ...
        f.Dispose()
 End Sub


Then your user must close the form2 before using form1 again.

Hope this helps

[EDIT] Don't forget to Dispose a form shown with ShowDialog. - DSK[/EDIT]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900