Results 1 to 10 of 10

Thread: Closing Window

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2001
    Posts
    416

    Closing Window

    Hi,

    In on of my VB.NET form, it will display some customer information.
    However, if the customer does not exist, I want to close the window itself.

    I've tried to put Me.Close inside the form's Load, Activated, HandleCreated, but I always get an error!

    What is the proper way to achieve this goal?

    Thx a lot!

  2. #2
    Addicted Member
    Join Date
    Jun 2004
    Location
    USA
    Posts
    172

    Re: Closing Window

    Me.Hide to hide it, or to unload it, I think you can use Unload Me, but I'm not sure if .NET has unload in it.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2001
    Posts
    416

    Re: Closing Window

    Hi,

    I think I won't hide it, but just unload (close) it.
    However, my problem is not how to close, but where to close!

    Thx~

  4. #4
    Hyperactive Member fret's Avatar
    Join Date
    Sep 2004
    Posts
    472

    Re: Closing Window

    Quote Originally Posted by stm
    Hi,

    In on of my VB.NET form, it will display some customer information.
    However, if the customer does not exist, I want to close the window itself.

    I've tried to put Me.Close inside the form's Load, Activated, HandleCreated, but I always get an error!

    What is the proper way to achieve this goal?

    Thx a lot!
    where did you put your checking in your customer information?

  5. #5
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    Re: Closing Window

    Quote Originally Posted by fret
    where did you put your checking in your customer information?
    Fret is correct only display the form if the customers exists.
    "The dark side clouds everything. Impossible to see the future is."

  6. #6
    Addicted Member
    Join Date
    Aug 2002
    Location
    top of the mountain
    Posts
    234

    Re: Closing Window

    Hi, this is one of possible solutions:
    VB Code:
    1. private customerExist as boolean
    2.  
    3.     Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    4.         ' put your code for check if customer exist
    5.         customerExist = CS_Exist()
    6.     End Sub
    7.  
    8.     ' and when you call Customer form in application
    9.     Dim frm As New FormCustomer
    10.     if frm.customerExist then
    11.         frm.ShowDialog
    12.     else
    13.         MessageBox.Show("There is no customers !")
    14.     end if
    15.     frm.dispose()

    regard j

  7. #7
    Fanatic Member
    Join Date
    Jun 2004
    Location
    All useless places
    Posts
    917

    Re: Closing Window

    Originally posted by janis
    frm.dispose()
    I hope the answer to the stm's answer is this statement.

  8. #8
    Member saraab's Avatar
    Join Date
    Jul 2004
    Location
    Pakistan
    Posts
    32

    Re: Closing Window

    How about using Application.exit()

  9. #9
    Fanatic Member
    Join Date
    Jun 2004
    Location
    All useless places
    Posts
    917

    Re: Closing Window

    The question is
    Originally posted by stm
    However, if the customer does not exist, I want to close the window itself.
    He doesn't want to close the application, simply the form which contains the details of the customer.

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2001
    Posts
    416

    Re: Closing Window

    Hi Janis,

    I got the idea, I will try, thx a lot!

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