Hi,
I want to know,the difference between form.show() and form.showDialog()?
Regards,
Hems.
Printable View
Hi,
I want to know,the difference between form.show() and form.showDialog()?
Regards,
Hems.
Form show will load it and then go on with the sub/function, ShowDialog will show it and wait until the form is closed before going on with the sub/functionQuote:
Originally Posted by haihems
Hi,
So, if I put form.Show(), then what i write in the Load event of the form will execute...for Showdialog(), the form will be shown and wait for any event, like button click...Am i right? :rolleyes:Quote:
Originally Posted by RudyL
Tell me what i understand is correct or not?? :eek:
Thanks.
Quote:
Originally Posted by haihems
No, not exactly..
For ShowDialog:
The code in the form will execute with out any hinderance..
The code in the calling sub/function will not execute until the form has been closed..
For Show:
The sub will call the form and go on, the code in the form will also be executed right away..
For example, if you have a sub like this:
This sub will load the form and then the program will immediatly endCode:sub main
mainform.show
end
end sub
But with this example:
The form will load and then stop executing code in sub main. Once the form is closed it will continue on..Code:sub main
mainform.showDialog
end
end sub
Try it and you will better understand it.
Hi RudyL,
Thanks for your explanation. I tried it and feel the difference.
Regards,
Hems. :wave:
No problem.. Glad to helpQuote:
Originally Posted by haihems
Hi Rudyl,
One more doubt on the same topic.
I tried to show frmTwo, from frmOne by clicking a button. My intension is while showing frmTwo, frmOne should be hidden. My coding...
VB Code:
In frmOne.... Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim nf As New frmTwo Me.Hide() nf.ShowDialog() End Sub
While clicking this button, the coding part of this project shown for 1 sec and the frmTwo loaded. I found that its bcos of hiding the ME first then showing the next form..I tried by putting the Me.hide after the showDialog,which is not executing and the frmOne will remain without hiding... :rolleyes:
What is wrong with my coding?? :eek:
Anybody can help...Thanks.
Regards,
Hems.
try
Code:dim nf as new frmTwo
nf.showdialog
if me.visible = true
me.hide
end if
Hi Grunt,
I've tried ur coding..but the frmOne is still visible...my previous code is working fine but the only i find the form get flickered before it loads...how can i resolve it?
Regards,
Hems.
I feel this has not been fully explored.
Form.Show is a Sub, but Form.ShowDialog is a Function that returns value.
When Showdialog is called, the process switches to the new form and the old form halts. The new form is available to the user as normal. When the user closes the new form (by hitting OK or Cancel or whatever) the Showdialog Function returns a value identifying whatever button the user clicked (OK or Cancel). The new form then gets unloaded and the old form goes back into action. The sub that called newform.Showdialog receives the returned value and acts upon it accordingly.
It is possible to (using OOP techniques) to devise a form.ShowDialog function that can return custom class instances instead of the normal OK or Cancel results. This is potentially extremely powerful.
Only a little bit more:
The Form which calls showdialog function is not completely stopped. If you have a timer running on it, it will continue to do its job. I had this experience months ago. I was confused because I believed all action on Form should be freezed, but it's not so. So, if you plan to use a timer, be careful on this point!
Good holidays, friends! :) :wave: