Results 1 to 11 of 11

Thread: Simple Question

  1. #1

    Thread Starter
    Addicted Member haihems's Avatar
    Join Date
    Oct 2004
    Posts
    150

    Question 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

  2. #2
    Frenzied Member RudyL's Avatar
    Join Date
    Mar 2001
    Location
    Chicago
    Posts
    1,519

    Re: Simple Question

    Quote 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".

  3. #3

    Thread Starter
    Addicted Member haihems's Avatar
    Join Date
    Oct 2004
    Posts
    150

    Re: Simple Question

    Hi,

    Quote 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.

  4. #4
    Frenzied Member RudyL's Avatar
    Join Date
    Mar 2001
    Location
    Chicago
    Posts
    1,519

    Re: Simple Question

    Quote 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".

  5. #5

    Thread Starter
    Addicted Member haihems's Avatar
    Join Date
    Oct 2004
    Posts
    150

    Thumbs up Re: Simple Question

    Hi RudyL,

    Thanks for your explanation. I tried it and feel the difference.

    Regards,
    Hems.

  6. #6
    Frenzied Member RudyL's Avatar
    Join Date
    Mar 2001
    Location
    Chicago
    Posts
    1,519

    Re: Simple Question

    Quote 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".

  7. #7

    Thread Starter
    Addicted Member haihems's Avatar
    Join Date
    Oct 2004
    Posts
    150

    Question 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:
    1. In frmOne....
    2. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    3.         Dim nf As New frmTwo
    4.         Me.Hide()
    5.         nf.ShowDialog()
    6.     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.

  8. #8
    Hyperactive Member Grunt's Avatar
    Join Date
    Oct 2004
    Location
    Las Vegas
    Posts
    499

    Re: Simple Question

    try

    Code:
    dim nf as new frmTwo
    
    nf.showdialog
    
    if me.visible = true
       me.hide
    end if

  9. #9

    Thread Starter
    Addicted Member haihems's Avatar
    Join Date
    Oct 2004
    Posts
    150

    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.

  10. #10
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    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.

  11. #11
    Hyperactive Member
    Join Date
    Mar 2004
    Location
    Prato - Tuscany - Italy
    Posts
    461

    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
  •  



Click Here to Expand Forum to Full Width