|
-
Dec 20th, 2004, 09:18 PM
#1
Thread Starter
Addicted Member
Simple Question
Hi,
I want to know,the difference between form.show() and form.showDialog()?
Regards,
Hems.
Last edited by haihems; Dec 20th, 2004 at 11:52 PM.
Reason: Resolved
-
Dec 20th, 2004, 09:32 PM
#2
Frenzied Member
Re: Simple Question
 Originally Posted by haihems
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/function
10 different ways to skin a cat and amazingly enough each and every one has the same result, the cat gets skinned! The same can be applied to code, so be nice and accept each others "preferences".
-
Dec 20th, 2004, 09:39 PM
#3
Thread Starter
Addicted Member
Re: Simple Question
Hi,
 Originally Posted by RudyL
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/function
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?
Tell me what i understand is correct or not??
Thanks.
-
Dec 20th, 2004, 09:44 PM
#4
Frenzied Member
Re: Simple Question
 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?
Tell me what i understand is correct or not??
Thanks.
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:
Code:
sub main
mainform.show
end
end sub
This sub will load the form and then the program will immediatly end
But with this example:
Code:
sub main
mainform.showDialog
end
end sub
The form will load and then stop executing code in sub main. Once the form is closed it will continue on..
Try it and you will better understand it.
10 different ways to skin a cat and amazingly enough each and every one has the same result, the cat gets skinned! The same can be applied to code, so be nice and accept each others "preferences".
-
Dec 20th, 2004, 09:52 PM
#5
Thread Starter
Addicted Member
Re: Simple Question
Hi RudyL,
Thanks for your explanation. I tried it and feel the difference.
Regards,
Hems.
-
Dec 20th, 2004, 09:54 PM
#6
Frenzied Member
Re: Simple Question
 Originally Posted by haihems
Hi RudyL,
Thanks for your explanation. I tried it and feel the difference.
Regards,
Hems. 
No problem.. Glad to help
10 different ways to skin a cat and amazingly enough each and every one has the same result, the cat gets skinned! The same can be applied to code, so be nice and accept each others "preferences".
-
Dec 20th, 2004, 11:51 PM
#7
Thread Starter
Addicted Member
Re: Simple Question
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...
What is wrong with my coding??
Anybody can help...Thanks.
Regards,
Hems.
-
Dec 21st, 2004, 01:34 AM
#8
Hyperactive Member
Re: Simple Question
try
Code:
dim nf as new frmTwo
nf.showdialog
if me.visible = true
me.hide
end if
-
Dec 21st, 2004, 03:32 AM
#9
Thread Starter
Addicted Member
Re: Simple Question
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.
-
Dec 21st, 2004, 05:27 AM
#10
Re: Simple Question
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.
I don't live here any more.
-
Dec 21st, 2004, 06:02 AM
#11
Hyperactive Member
Re: Simple Question
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!
Live long and prosper (Mr. Spock)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|